【问题标题】:-[UIImagePickerController respondsToSelector:]: message sent to deallocated instance in iOS-[UIImagePickerController respondsToSelector:]:消息发送到 iOS 中已释放的实例
【发布时间】:2015-02-04 09:36:37
【问题描述】:

我使用 UIImagePickerController 从相机中捕获真实照片。它曾经可以工作,但是使用 iOS8 我面临崩溃。下面是代码和崩溃日志。

UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
 imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
[self.navigationController presentViewController:imagePicker animated:YES completion:nil];

- (void)imagePickerControllerDidCancel:(UIImagePickerController *) Picker {

    [self.navigationController dismissViewControllerAnimated:YES completion:nil];

}

日志: 对尚未渲染的视图进行快照会导致快照为空。确保您的视图在快照之前或屏幕更新后的快照之前至少渲染过一次。

-[UIImagePickerController respondsToSelector:]:消息发送到释放的实例

重现问题的步骤是, 1.点击App中的相机按钮。 2. 相机打开。 3. 单击相机 UI 上的取消。 4. 再次点击相机按钮,App现在崩溃了。

【问题讨论】:

  • 您是否在任何地方释放 ImagePicker?
  • 项目中有ARC吗?
  • 你在模拟器上吗?因为你不能在模拟器上使用 UIImagePickerControllerSourceTypeCamera。
  • @Tendulkar:我正在使用 ARC,而不是在任何地方解除分配。
  • @TheRonin:我只在设备上进行测试。

标签: ios iphone ios8 uiimagepickercontroller ios8.1


【解决方案1】:

你应该使用 [self presentViewController:imagePicker Animation:YES 完成:nil];

和 [self dismissViewControllerAnimated:YES 完成:nil];

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。我通过在这两种方法的动画参数中传递“NO”来解决它:

    [self presentViewController:imagePickerController animated:NO completion:nil];
    [self dismissViewControllerAnimated:NO completion:nil];
    

    【讨论】:

      猜你喜欢
      • 2012-07-14
      • 2017-05-12
      • 2012-05-19
      • 2013-08-17
      • 2013-04-13
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多