gpt4 book ai didi

iphone - 从 UIImagePickerController 呈现另一个模态视图

转载 作者:行者123 更新时间:2023-12-03 18:39:55 25 4
gpt4 key购买 nike

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

我的 UIImagePickerController 从我的一个 View Controller 中以模态方式呈现,该 View Controller 由导航 Controller 控制,而导航 Controller 又由选项卡栏 Controller 控制。

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

- (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];
}

但是,这会使应用程序崩溃。我应该从选择器中以模式方式呈现确认 View 吗?如果是这样,我如何确保当确认 View 被关闭时,选择器也不会显示?

编辑:

修复了我发布的代码中的错误。这就是当我尝试从内存中输入而不是复制+粘贴时发生的情况:(无论如何,到目前为止的建议没有帮助。

如果我呈现模态 Controller 然后关闭选择器,则不会发生任何事情,大概是因为两个 Controller 随后都被关闭了。

如果我关闭选择器然后显示模态 Controller ,我会收到有关模态转换的异常:

*** 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'

最佳答案

找到了解决方案。事实上,需要关闭选择器,技巧是关闭该关闭的动画,以便它立即发生,然后呈现第二个模态视图。

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

我还尝试保留选择器而不是关闭它。相反,我调用[picker presentModalViewController:modalAnimated:YES]。这让我可以顺利地从选择器过渡到确认 View 。但是,当我完成确认 View 时,我需要从原始 Controller 调用 [self DismissModalViewControllerAnimated:YES] 。这具有在忽略所有内容之前先显示图像选择器的效果。再说一遍,这并不完全是我想要的。

理想情况下,我想要 Facebook iPhone 应用程序用于上传照片的相同效果。选择照片后,它会无缝过渡到确认 View 。从该 View 取消或确认将平滑地过渡回原始主视图。它使得确认 View 看起来像是图像选择器的一部分,而实际上它可能只是另一个自定义 View 。

我该怎么做?

关于iphone - 从 UIImagePickerController 呈现另一个模态视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3799879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com