草庐IT

iphone - UIImagePickerController subview 未调用委托(delegate)。用作 modalViewController

coder 2024-01-27 原文

我正在使用 UIImagePickerController 编写相机应用程序,我想将它作为 subview 添加到显示层次结构中:

id delegate = [[UIApplication sharedApplication] delegate];
window = [delegate window];

picker.cameraViewTransform = CGAffineTransformMakeScale(1.3, 1.3);
[window addSubview:picker.view];
[picker viewWillAppear:YES];
[picker viewDidAppear:YES];

但是当我这样做时,委托(delegate)没有被调用。

picker 是一个 UIImagePickerController 实例。

如果我将代码从将其添加为 subview 更改为:

[[UIApplication sharedApplication].keyWindow.rootViewController presentModalViewController: controller animated: YES];

然后一切正常。我相当确定我已正确设置委托(delegate)。如果我可以发布更多代码以提供更多帮助,请告诉我。我不确定要发布什么。

我正在为 Adob​​e Flex Native Extension 执行此操作,因此我必须做一些额外的工作才能获得对窗口的引用。这也是我不能使用 modalViewController 的原因。 Flex 应用程序需要将其窗口保留在 View 层次结构中的 UIImagePickerController 下,以便我稍后可以返回它。

非常感谢任何帮助 谢谢

最佳答案

我还将 uiimagepicker 添加为另一个 View 的 subview 。我通过确保图像选择器是一个 ivar 或维护指向它的强指针以使其得以保留来解决此问题。

关于iphone - UIImagePickerController subview 未调用委托(delegate)。用作 modalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776088/

有关iphone - UIImagePickerController subview 未调用委托(delegate)。用作 modalViewController的更多相关文章

随机推荐