如何使用 UIPopOverController 使使用 ImagePicker 的 iPhone 应用程序在 iPhone 上运行?
我正在制作一个通用应用程序,它在 iPhone 上运行得很好!但在 iPad 上,它无法调出图像选择器。代码是:
- (IBAction)openImagePicker:(id)sender //Makes UIImagePicker roll up from the bottom.
{
UIActionSheet *alertSheet = [[UIActionSheet alloc] initWithTitle:@"Where do you want to get your daily image?" delegate:(self) cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Library", nil];
[alertSheet setTag:0];
[alertSheet setDelegate:self];
[alertSheet showFromTabBar:[[self tabBarController] tabBar]];
[alertSheet release];
}
它说原因是“*由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'在iPad上,UIImagePickerController必须通过UIPopoverController呈现'”我该怎么做?感谢您的帮助。
I am making a universal app, and it works great on the iPhone! But on the iPad, it cannot pull up the image picker. The code is:
- (IBAction)openImagePicker:(id)sender //Makes UIImagePicker roll up from the bottom.
{
UIActionSheet *alertSheet = [[UIActionSheet alloc] initWithTitle:@"Where do you want to get your daily image?" delegate:(self) cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Library", nil];
[alertSheet setTag:0];
[alertSheet setDelegate:self];
[alertSheet showFromTabBar:[[self tabBarController] tabBar]];
[alertSheet release];
}
It says the reason is "* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController'" How do I do this? Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须检查应用程序安装在哪种类型的设备习惯上,然后适当地显示控制器。您可以执行以下操作:
不要忘记实现 UIPopoverController 委托方法。
祝你好运
You will have to check for which type of device idiom the app is installed on and then present the controller appropriately. You can do something along the lines of the following:
don't forget to implement the UIPopoverController delegate methods.
Good Luck