在弹出窗口中呈现模态视图
我试图从弹出窗口中显示的视图控制器加载模态视图。模式视图加载,但问题是它转换到主视图而不是弹出窗口内。我缺少什么吗?我认为简单地从弹出窗口中的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您
在调用 presentModalViewController:animated 之前添加,您的 ModalVC 应该显示在弹出窗口中。
在弹出窗口中以模态方式显示内容的另一种方法是使用属性 modalInPopover。
If you add
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.
不幸的是,您似乎不能这样做,并且它违反了 HIG。来自苹果的 查看控制器编程指南
Unfortunately, it seems you cannot to this and it violates the HIG. From Apple's View Controller Programming Guide
这是因为您将
presentModalViewController
呈现给self
。尝试在 ViewController (自身)中添加 UIBarButtonItem 并执行以下操作:其中
sender
是UIBarButtonItem
It's because you
presentModalViewController
toself
. Try to add a UIBarButtonItem in your ViewController (self) and do:where
sender
is theUIBarButtonItem