iOS-UIImagePickerController 内存警告研究

在iOS开发具有拍照功能的APP的时候会出现内存警告黑屏的问题,因此我们判断当self.presentedViewControlle是UIImagePickerController 类型时,不做内存警告处理。这样就可以避免这样的问题。


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

    UIViewController *n = self.navigationController;
    UIViewController *s = n.tabBarController.selectedViewController;
    UIViewController *t = self.navigationController.topViewController;
    UIViewController *v = self.presentedViewController;

    if(t == self
       && (s == n || !s)
       && ([v isKindOfClass:[UIImagePickerController class]]))
    {
        NSLog(@"ignore didReceiveMemoryWarning %@",self.description);
        return;
    }

    NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
    CGFloat sysVersion = [systemVersion floatValue];
    if (sysVersion >= 6.0)
    {
        if(self.isViewLoaded && !self.view.window){
            self.tableView = nil;
            self.view = nil;
        }
    }

}

你可能感兴趣的:(iOS,随手记,内存管理,移动开发)