从UIImagePickerController呈现另一个模态视图

我想在用户拍摄照片或选择保存的照片后添加确认视图。 确认视图将显示所选图像,并在工具栏中显示取消和上传按钮。

我的UIImagePickerController以模式方式从我的一个视图控制器呈现,它由导航控制器控制,而导航控制器又由标签栏控制器控制。

如何以模态方式显示我的确认视图,以便在用户选择照片时占用全屏幕(如图像选择器视图)? 理想情况下,我想要这样的东西:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    UIViewController *modal = [[UIViewController alloc] init];
    modal.view = confirmationView;
    [self presentModalViewController:modal animated:YES];
    [modal release];
}

但是,这会导致应用程序崩溃。 我应该从PICKER中以模态形式呈现确认视图吗? 如果是这样,我如何确保在确认视图被解除时,选取器也不会显示?

编辑:

修正了我发布的代码中的错误。 这就是当我尝试从内存中键入而不是复制+粘贴:(反正,迄今为止的建议没有帮助。

如果我介绍模态控制器然后解除选取器,则不会发生任何事情,据推测,因为这两个控制器随后被解雇。

如果我解雇了选择器,那么现在的模态控制器,我得到一个关于模态转换的例外:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <UINavigationController: 0x6b33940> to <UIViewController: 0x6b62b00> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'

找到解决方案。 事实上,挑选者需要被解雇,关键在于为解雇而关闭动画,以便立即发生,然后呈现第二个模态视图。

编辑:其实,它让我几乎到了我想要的。 当您关闭选取器时,原始视图会在瞬间显示,然后模态视图会变成动画。 这看起来有点时髦。

我也试着让选择者保持不动,而不是解雇它。 相反,我调用[picker presentModalViewController:modal animated:YES] 。 这使我可以顺利地从选取器转换到确认视图。 但是,当我完成确认视图时,我需要从原始控制器调用[self dismissModalViewControllerAnimated:YES] 。 这会在解散所有内容之前首先显示图像选择器。 再次,不是我想要的。

理想情况下,我希望Facebook iPhone应用用于上传照片的效果相同。 一旦你选择了一张照片,它将无缝转换到确认视图。 从该视图中取消或确认将平滑过渡回原始主视图。 它使得它看起来像确认视图是图像选择器的一部分,当它可能只是另一个自定义视图。

我该怎么做呢??


尝试这个...

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIViewController *modal = [[UIViewController alloc] init];
    modal.view = confirmationView;
    picker.navigationController pushViewController:modal animated:YES];
    [modal release];
}

你在发布之前发布模态。 尝试这个:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIViewController *modal = [[UIViewController alloc] init];
    modal.view = confirmationView;
    [self presentModalViewController:modal animated:YES];
    [modal release];
    [picker dismissModalViewControllerAnimated:YES];
}
链接地址: http://www.djcxy.com/p/48091.html

上一篇: Present another modal view from UIImagePickerController

下一篇: Is there a way to download Xcode on its own?