在弹出窗口中呈现模态视图

发布于 2024-09-01 04:06:08 字数 340 浏览 13 评论 0原文

我试图从弹出窗口中显示的视图控制器加载模态视图。模式视图加载,但问题是它转换到主视图而不是弹出窗口内。我缺少什么吗?我认为简单地从弹出窗口中的 vc 启动它就会在同一个弹出窗口中呈现模态视图...

代码没有什么特别的,如下所示:

- (IBAction)myButton{
ModalVC *controller = [[ModalVC alloc] initWithNibName:@"ModalVC" bundle:nil];

[self presentModalViewController:controller animated:YES];
[controller release]; }

Im trying to load a modal view from a view controller that is displayed in a popover. The modal view loads but the problem is that it transitions into the main view and not within the popover. Is it something Im missing? I thought simply initiating it from a vc within a popover would present the modal view within the same popover...

The code is nothing special as bellow:

- (IBAction)myButton{
ModalVC *controller = [[ModalVC alloc] initWithNibName:@"ModalVC" bundle:nil];

[self presentModalViewController:controller animated:YES];
[controller release]; }

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

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

发布评论

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

评论(3

风追烟花雨 2024-09-08 04:06:08

如果您

controller.modalPresentationStyle = UIModalPresentationCurrentContext;

在调用 presentModalViewController:animated 之前添加,您的 ModalVC 应该显示在弹出窗口中。

在弹出窗口中以模态方式显示内容的另一种方法是使用属性 modalInPopover。

If you add

controller.modalPresentationStyle = UIModalPresentationCurrentContext;

before the call to presentModalViewController:animated your ModalVC should be displayed within the popover.

Another way to display something modally in a popover is to use the property modalInPopover.

夏雨凉 2024-09-08 04:06:08

不幸的是,您似乎不能这样做,并且它违反了 HIG。来自苹果的 查看控制器编程指南

注意:在显示之前,您应该始终关闭可见的弹出窗口
另一个模态视图控制器。有关何时和的具体指南
如何在应用程序中使用弹出框,请参阅“弹出框(仅限 iPad)”
iOS 人机界面指南。

Unfortunately, it seems you cannot to this and it violates the HIG. From Apple's View Controller Programming Guide

Note: You should always dismiss the visible popover before displaying
another view controller modally. For specific guidelines on when and
how to use popovers in your application, see “Popover (iPad Only)” in
iOS Human Interface Guidelines.

遥远的她 2024-09-08 04:06:08

这是因为您将 presentModalViewController 呈现给 self。尝试在 ViewController (自身)中添加 UIBarButtonItem 并执行以下操作:

[controller presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

其中 senderUIBarButtonItem

It's because you presentModalViewController to self. Try to add a UIBarButtonItem in your ViewController (self) and do:

[controller presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

where sender is the UIBarButtonItem

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