ios – 呈现UIImagePickerController时检测到泄漏

ios – 呈现UIImagePickerController时检测到泄漏,第1张

概述这是我用来呈现UI ImagePickerController的代码: - (IBAction)takePhoto:(UIButton *)sender { if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIAlert 这是我用来呈现UI ImagePickerController的代码:

- (IBAction)takePhoto:(UIbutton *)sender {  if (![UIImagePickerController          isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {    UIAlertController *alert = [UIAlertController        alertControllerWithTitle:NSLocalizedString(@"Error",nil)                         message:NSLocalizedString(@"Device has no camera",nil)                  preferredStyle:UIAlertControllerStyleAlert];    UIAlertAction *ok =        [UIAlertAction actionWithTitle:NSLocalizedString(@"OK",nil)                                 style:UIAlertActionStyleDefault                               handler:nil];    [alert addAction:ok];    [self presentVIEwController:alert animated:YES completion:nil];  } else {    UIImagePickerController *picker = [[UIImagePickerController alloc] init];    picker.delegate = self;    picker.allowsEditing = YES;    picker.sourceType = UIImagePickerControllerSourceTypeCamera;    picker.vIDeoQuality = UIImagePickerControllerQualityTypeMedium;    [self presentVIEwController:picker animated:YES completion:NulL];  }}

目前我运行这个方法(例如点击UIbutton)我可以在仪器中看到这个:

这就是我所看到的,如果我改为Cycles&根源:

因此,如果我将鼠标悬停在第一次泄漏上,然后按下d出的箭头,我会得到:

如果我为这个方法打开堆栈跟踪,我看到:

所以主要是系统调用.同样适用于其他泄漏,只是系统调用……所以这是一个BUG还是?如果我几次打开和关闭图像选择器,我会得到更多的泄漏,更多……

有人注意到了吗?

解决方法 你需要使UIImagePickerController * picker成为一个强大的属性.因此,该应用程序具有对该选择器的全局引用,您将能够将其解雇. 总结

以上是内存溢出为你收集整理的ios – 呈现UIImagePickerController时检测到泄漏全部内容,希望文章能够帮你解决ios – 呈现UIImagePickerController时检测到泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005900.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存