UIImagePickerController
iOS6アプリでモーダルを表示するときに奇妙な問題が発生します。はXCode
私にこのエラーを与えます:
Warning: Attempt to present <UIImagePickerController: 0x1e025040> on <UINavigationController: 0x1d51ce00> whose view is not in the window hierarchy!
私の中には次のウィンドウ階層がありますAppDelegate
:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
firstViewController = [[SGNewMailViewController alloc] init];
navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
self.window.rootViewController = firstViewController;
[self.window makeKeyAndVisible];
return YES;
}
私の中で、SGNewMailViewController
私は新しい、このコードを含むクラスUIView
のメンバーを提示します:SGFoldingAttachmentView
- (void)choosePhotoPressed {
SGNewMailViewController *mailVC = [((SGAppDelegate *)[UIApplication sharedApplication].delegate).firstViewController.navigationController.viewControllers lastObject];
[mailVC displayCameraRoll];
}
最後に、これが私のSGNewMailViewController
displayCameraRoll
方法です:
- (void)displayCameraRoll {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
では、何が問題になる可能性がありますか?別のクラスから提示されたカスタムビューにありますか?どうすれば修正できますか?前もって感謝します!