如何通过将设备旋转到横向来引发模态视图弹出窗口?
我正在开发一个应用程序,我想在用户旋转设备时显示模式视图控制器。当用户将其旋转回纵向时,它应该消失。旋转期间,主视图控制器不应旋转。
我该如何处理?
我尝试将代码放入 shouldAutorotateToInterfaceOrientation:
方法中以显示模态视图控制器,但总是出现错误。
一些想法?
I am working on an App where I want to show a modal view controller when the user rotates the device. It should dismiss when the user rotates it back to portrait. During the rotation, the main view controller shouldn't be rotated.
How can I manage that?
I tried putting the code into the shouldAutorotateToInterfaceOrientation:
method for showing the modal view controller, but I got always an error.
Some ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 appDelegate 中,您可以使用
并定义该方法
,在此方法中,获取新方向并应用或删除模式视图控制器。
在
shouldAutorotateToInterfaceOrientation:
中,将原始视图限制为仅接受您希望其具有的一个方向。In the appDelegate you could use
and define the method
In this method, fetch the new orientation and apply or remove the modal view controller.
In
shouldAutorotateToInterfaceOrientation:
limit the original view to only accept the one orientation you want it to have.您需要将此代码放入
视图控制器的方法中。基本上,您将设置您的
shouldAutorotateToInterfaceOrientationMethod:
为您想要支持的任何方向(包括模态视图弹出窗口)返回 TRUE。然后在列出的第一个方法中,您实现模态视图控制器变为活动状态。you need to put this code in the
method of your view controller. Basically you will set your
shouldAutorotateToInterfaceOrientationMethod:
to return TRUE for any orientations you want to support (including the modal view popup). and then in the first method listed you implement the modal view controller becoming active.