当我在 IOS7.0.3 中使用 UIImagePickerController 时,它似乎会抛出错误“对未呈现的视图进行快照会导致快照为空”。我的代码如下所示
-(void) showCamera
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
委托方法是
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES
completion:nil];
NSString *mediaType = info[UIImagePickerControllerMediaType];
UIImage *image = nil;
if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeImage])
{
image = info [
UIImagePickerControllerOriginalImage];
}
if(picletImage != nil)
{
self.imageView.image = image;
}
}
我不知道这里出了什么问题,但这似乎在 iPad 上运行良好。我阅读了大量文章,但没有得到解决方案。我在仪器中进行了验证,似乎是在相机初始化期间或拍摄照片后发生了内存泄漏。在过去的 4 天里,我一直坚持这个问题,有人可以帮助我解决问题所在,也可以解决这个问题。