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.'
このアクション シートを両方のデバイスに設定するにはどうすればよいですか?
ありがとう!