UIImagePickerController iPad 问题

发布于 2024-09-11 18:30:44 字数 621 浏览 2 评论 0原文

我有以下代码:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] initWithRootViewController:self];
imagePicker.delegate = self;

popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[imagePicker release];
[popover presentPopoverFromRect:CGRectMake(100, 100.0, 0.0, 0.0) 
                         inView:self.view
       permittedArrowDirections:UIPopoverArrowDirectionAny 
                       animated:YES];

但这只会破坏 self.view 并且根本不显示任何内容。当我将 inView: 设置为 [self.view window] 时,选择器至少会显示出来。但它仍然删除了 self.view。我必须做什么才能使视图不会消失?

I have the following code:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] initWithRootViewController:self];
imagePicker.delegate = self;

popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[imagePicker release];
[popover presentPopoverFromRect:CGRectMake(100, 100.0, 0.0, 0.0) 
                         inView:self.view
       permittedArrowDirections:UIPopoverArrowDirectionAny 
                       animated:YES];

But this only destroys the self.view and does not show anything at all. When I set the inView: to [self.view window] the picker at least shows up. But it still removes the self.view. What do I have to do that the view doesn't disappear?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海未深 2024-09-18 18:30:44

您初始化 UIImagePickerController 错误。尝试将其更改为

[[UIImagePickerController alloc] init]

You are initializing the UIImagePickerController wrong. Try changing it to

[[UIImagePickerController alloc] init]
凑诗 2024-09-18 18:30:44

您正在尝试使用该视图本身在视图内显示弹出窗口!

initWithRootViewController 是要在弹出窗口中显示的视图(控制器)。

inview 是弹出窗口的视图

You are trying to show a popup inside a view with that view itself!

initWithRootViewController is the view(controller) to show inside the popup.

inview is the view where the popup will pop up

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文