在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; } } }
打赏作者
如果这篇文章帮助了你,可以请作者喝罐可乐,以此激励作者创作更多!

您的支持将鼓励我继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏