如何使 UIsplitview 的弹出窗口在纵向模式 iPad 中可见
我希望每当用户在 iPad 的 UIsplitView 中从横向视图切换到纵向视图时,弹出窗口视图就可见。虽然用户可以通过单击栏按钮使其可见,但我希望在纵向模式下自动执行此操作。
I would like to make popover view visible whenever user switches from landscape view to portrait view in UIsplitView of iPad. Although user can make it visible by clicking on bar button but I want this to be automated for portrait mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在“-(BOOL) shouldAutorotateToInterfaceOrientation”方法中,检查设备方向。如果是纵向,则像用户单击栏按钮时使其可见一样呈现弹出框。
一切顺利。
Inside " -(BOOL) shouldAutorotateToInterfaceOrientation" method, check for the device orientation.If it is portrait, then Present the popover as you do for making it visible when user clicks bar button.
All the best.
UISplitViewController 向他的委托 (UISplitViewControllerDelegate) 发送消息。您可以实现此委托方法来显示弹出窗口。您可以在“详细控制器”代码中执行类似的操作:
UISplitViewController sends messages to his delegate (UISplitViewControllerDelegate). You can implement this delegate methods to show the popover. You can do something like this in your "detail controller" code:
接受的答案(使用
shouldAutorotateToInterfaceOrientation
)对我不起作用。它要么有旋转伪影(在 4.2 和 5.0 iPad 模拟器中),要么仅在启动时显示,而在后续旋转中不再显示(4.3 模拟器)。我所做的是创建一个小辅助函数:并在
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
和- (void)viewDidLoad
中调用它来处理启动。The accepted answer (using
shouldAutorotateToInterfaceOrientation
) doesn't work for me. It either has rotation artifacts (in the 4.2 and 5.0 iPad simulators) or only shows at startup and never again in subsequent rotations (the 4.3 simulator). What I did instead was to create a little helper function:and call this within
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
and- (void)viewDidLoad
to also handle on startup.