iphone - 在 uiimagePickerController 完成后呈现一个带有模态的 viewController

标签 iphone objective-c ios ipad

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/

相关文章:

iphone - 单击按钮时如何增加标签值

iphone - 如何识别当前哪个文本字段是第一响应者

iphone - 如何比较两个 NSIndexPaths?

ios - 无法更改 UINavigationController 的色调

ios - 更改 UISearchBar 的字体大小

ios - 如何在iOS中基于String动态调整UITextview高度

ios - 从 iPhone 的日历中删除事件

ios - 如何使用 GPUImage 实现 GPUImageMaskFilter

ios - 如何将按钮添加到 tableview,以便它提取特定于按下它的单元格的用户数据?

ios - 对具有自己的转换的 ViewController 的不平衡调用