【发布时间】:2014-09-23 08:55:55
【问题描述】:
这是 iPhone 应用程序代码,但是当我遇到 ipad 视网膜模拟器或
ipad 时,应用程序就会崩溃。我已经检查了很多次,我意识到
选择器对象为零。但它在 iPhone 模拟器上效果很好。任何人对这件事有任何想法。(这个应用程序只制作了 iPhone,但在 iPad Retina 和 iPad 上运行)
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init]; // image picker alloc
imagePicker.delegate = self; // delegate call by self
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //Pick image in Library
[self presentModalViewController:imagePicker animated:YES]; // OPen Library
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
imgImage = info[UIImagePickerControllerOriginalImage]; //Get Orginial Images
imgData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((imgImage), 0.9)]; // Jpg image format
[picker dismissModalViewControllerAnimated:YES];
} // pick image from this method
【问题讨论】:
-
当它崩溃时,调试器中显示的错误信息具体是什么?
-
*** 由于未捕获的异常 'NSInvalidArgumentException' 导致应用程序终止,原因:'*** setObjectForKey: object cannot be nil (key: Image)' 如果你知道这件事,请帮助我。跨度>
-
崩溃所在行的内容是什么?你能提供它(以及任何周围的线条,如果可能的话)?
-
打印返回的 NSDictionary 也可能有助于调试目的,如下所示: NSLog(@"info = %@", info);
-
UIImage *myImage =[info objectForKey:UIImagePickerControllerOriginalImage];我得到了 nil myImage nil。并在其他线路上崩溃。
标签: objective-c iphone ios7 uiimageview ipad-2