UIPopoverController 中的 iPad UIImagePicker 仅选择保存的图像(不是来自相册)?
在我的 iPad 应用程序中,我让用户使用以下代码选择图像:(
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];
我已将该类设置为 UIPopoverControllerDelegate 和 UIImagePickerControllerDelegate,并且我已为这两个委托设置了回调。)
现在,奇怪的是,如果我从“保存的照片”相册中选择图像,我的“imagePickerController:didFinishPickingImage”回调方法就会被调用,并且我会得到一张图像,一切都很好。
但是,如果我从任何其他相册中选择图像,我的“imagePickerControllerDidCancel”回调将被调用 - 并且我不会取回图像。
有什么想法吗?我在网上搜索了很多...
谢谢, Reuven
情节变得更加复杂......
添加时:
允许编辑=是;
我仍然可以从“保存的照片”相册中选择(并裁剪/缩放)图像 - 但是当尝试使用其他相册中的图像时,iPad 崩溃,调试器显示:
2010-06-03 08:16:06.759 uPrintMobile[98412:207 ] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[NSCFDictionary setObject:forKey:]:尝试插入 nil 值(键:UIImagePickerControllerOriginalImage)”
仍然没有线索...
In my iPad application, I'm letting the user select an image using the following code:
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];
(I've set up the class to be both a UIPopoverControllerDelegate and a UIImagePickerControllerDelegate, and I've setup the callbacks for both delegates.)
Now, the weird thing is that if I select an image from the "Saved Photos" photo album, my "imagePickerController: didFinishPickingImage" callback method gets called, and I get an image, and all is well.
But, if I select an image from any of the other albums, my "imagePickerControllerDidCancel" callback gets called - and I don't get back an image.
Any idea? I've searched the web high-and-low...
Thanks,
Reuven
The plot thickens...
When adding:
allowsEditing = YES;
I can still select (and crop/scale) images from the Saved Photos album - but when trying to Use images from other albums, the iPad crashes with the debugger showing:
2010-06-03 08:16:06.759 uPrintMobile[98412:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: UIImagePickerControllerOriginalImage)'
Still no clue...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
UIImagePickerControllerSourceTypePhotoLibrary
的其他选项在您的委托方法中,检查条件,例如
Try playing around the other options of
UIImagePickerControllerSourceTypePhotoLibrary
in your delegate method, check the condition like
我知道这是很多个月后的事了,但我为同样的问题而苦苦挣扎,发现虽然这里被问了很多次,但从未得到答复。好吧,我很高兴地说我已经弄清楚了,因此我将其发布在搜索中首先出现的一些几乎相同的问题上。
我在这里发布了完整的答案:
didFinishPickingMediaWithInfo 返回零照片
I know this is many months later, but I struggled with the same problem and found that though it was asked here many times, it was never answered. Well, I'm happy to say that I figured it out and so am posting it on a few of the nearly-identical questions that come up first on a search.
I posted the full answer here:
didFinishPickingMediaWithInfo return nil photo