UIActionSheet でボタンをクリックした後に UIImagePickerController を表示しようとしています。コードは簡単です。ただし、への呼び出しは終了するまで数秒間[[UIImagePickerController alloc] init]
ハングします。この動作はシミュレーターでは見られませんが、iPod と iPhone では見られます。
UIActionSheetDelegate メソッドは次のとおりです。実行時間を表示するログ メッセージが追加されました。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"Action sheet clicked button at index %d", buttonIndex);
switch (buttonIndex) {
case kSelectFromCameraButtonIndex:
[self showImagePickerWithCamera];
break;
case kSelectFromPhotoLibraryButtonIndex:
[self showImagePickerWithPhotoLibrary];
break;
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"Action sheet will dismiss with button index %d", buttonIndex);
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"Action sheet did dismiss with button index %d", buttonIndex);
}
UIImagePickerController を実際に作成するコードは次のとおりです。
- (void)showImagePickerWithPhotoLibrary {
NSLog(@"Showing image picker with photo library");
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
NSLog(@"Creating picker");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
NSLog(@"Setting picker settings");
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
NSLog(@"Presenting picker as modal view controller");
[self presentModalViewController:picker animated:YES];
NSLog(@"Releasing picker");
[picker release];
}
}
派手なことは何もありません。ただし、コンソール出力を見ると、UIImagePickerController が作成される行が完了するまでに約7 秒かかることがわかります。
2010-09-21 15:23:26.107 Oh Snap[1264:307] Action sheet clicked button at index 1
2010-09-21 15:23:26.113 Oh Snap[1264:307] Showing image picker with photo library
2010-09-21 15:23:26.120 Oh Snap[1264:307] Creating picker
2010-09-21 15:23:33.111 Oh Snap[1264:307] Setting picker settings
2010-09-21 15:23:33.123 Oh Snap[1264:307] Presenting picker as modal view controller
2010-09-21 15:23:33.136 Oh Snap[1264:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2010-09-21 15:23:33.144 Oh Snap[1264:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
2010-09-21 15:23:33.289 Oh Snap[1264:307] Releasing picker
2010-09-21 15:23:33.299 Oh Snap[1264:307] Action sheet will dismiss with button index 1
2010-09-21 15:23:33.916 Oh Snap[1264:307] Action sheet did dismiss with button index 1
誰がこれを引き起こしているのか知っていますか?