我正在执行操作表,以便弹出3个选项,拍照,选择照片或取消。该应用程序最初仅适用于ipad,但现在我正在iphone上实现它。问题似乎出在界面上,因为它是在ipad上设置的。
这是代码:
#pragma mark - UIActionSheetDelegate methods
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
CustomImagePickerController *imagePicker = [[CustomImagePickerController alloc] init];
[imagePicker setDelegate:self];
[imagePicker setAllowsEditing:YES];
if(buttonIndex == 0) {
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else if(buttonIndex == 1) {
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
CGSize winsize = [[CCDirector sharedDirector] winSize];
CGRect rect = CGRectMake(20,20,10,10);
rect.origin = [[CCDirector sharedDirector] convertToGL:rect.origin];
_popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[_popoverController setDelegate:self];
[_popoverController setPopoverContentSize:CGSizeMake(winsize.width, winsize.height) animated:NO];
[_popoverController presentPopoverFromRect:rect inView:[[CCDirector sharedDirector] view] permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
这是错误:
2013-02-27 15:35:31.437 xxxxxxxx [8492:707] cocos2d: surface size: 480x320
2013-02-27 15:35:32.848 xxxxxxxx [8492:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.'
如何将此操作表设置到两个设备?
谢谢!
最佳答案
在iPhone或iPod Touch上不能使用UIPopoverViewController
,这是只能在iPad上实例化的类。
关于ios - 其他接口(interface)/设备的操作表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15119881/