从 imagePickerController
选择图像后,我需要调用 View Controller ,因此我使用了以下代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
imageEditorView = [[ImageEditorViewController alloc]initWithNibName:@"ImageEditorViewController" bundle:nil];
imageEditorView.mainViewController = self;
imageEditorView.imageBG = [info objectForKey:UIImagePickerControllerOriginalImage];
[self presentViewController:imageEditorView animated:YES completion:nil];
}
但是调试器给了我这个警告:
Warning: Attempt to present <ImageEditorViewController: 0xaa42320> on
<ViewController: 0x9b58680> whose view is not in the window hierarchy!
什么也没有呈现!
如果我 dissMiss 它第一个调试器会给我这个错误:
Warning: Attempt to present <ImageEditorViewController: 0xa913980> on
<ViewController: 0x9b332a0> while a presentation is in progress
!
已编辑
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
最佳答案
使用以下代码:
[self dismissViewControllerAnimated:YES completion:^{
[self.parentViewController presentViewController:imageEditorView animated:YES completion:nil];
}];
关于iphone - 在 uiimagePickerController 完成后呈现一个带有模态的 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14020576/