模态视图的 iPad 方向问题
我的模态视图旋转有问题。 我以纵向模式创建主视图,然后创建模态视图。一切正常:我可以旋转模态视图并且支持所有方向。 如果我以纵向模式创建主视图,然后以横向旋转,然后创建模态视图...模态处于纵向模式,而不是应有的横向模式。
主视图和模态视图中的shouldAutorotateToInterfaceOrientation都返回YES。
有什么想法吗?
i've a problem with a modal view rotation.
I create a main view in portrait mode, then i create a modal view. Everything works fine: i can rotate the modal view and all orientation are supported.
If i create the main view in portrait mode then rotate in landscape and after that i create my modal view... the modal is in portrait mode and not in landscape as it should be.
Both shouldAutorotateToInterfaceOrientation in main view and modal view return YES.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
遇到了同样的问题,最终修复了模式延迟一秒钟的问题,因此“父”视图控制器可以获得正确的方向。
现在登录看起来像:
Had the same issue, finaly fixed delaying the modal for a second, so the 'parent' view controller could get the correct orientation.
presentLogin looks like:
如果视图控制器在 iOS 将旋转事件排队之后但在处理旋转事件之前呈现,则可能会发生这种情况。根据观察,我认为旋转事件特定于当前呈现的视图控制器。
这是一种有用的思考方式:
值得庆幸的是,有一个非常简单的修复方法。假设事件队列中有一个旋转事件,并确保您的视图实际上在它之后呈现。您可以通过对新视图控制器的呈现进行排队来完成此操作,而不是直接呈现它。排队到主队列的块将在任何已排队的事件(如旋转事件)之后、但在用户有机会与您的 UI 交互之前执行。
更改
为:
执行此操作后,您会得到以下行为:
This can happen if the view controller is being presented after iOS queues a rotate event, but before the rotate event is handled. From observation, I think rotate events are specific to the view controllers currently being presented.
This is a helpful way of thinking of it:
Thankfully, there's a really easy fix. Just assume there's a rotate event in the event queue, and make sure your view is actually presented after it. You do this by queuing the presentation of your new view controller, rather than presenting it directly. Blocks queued to the main queue will be executed after any events already queued (like rotate events) but before the user gets a chance to interact with your UI.
Change:
To:
After doing this, you get this behaviour instead:
我有同样的问题。我最终通过从主视图控制器(而不是从子视图之一的视图控制器)显示模态视图来解决这个问题。
I had the same issue. I finally worked around it by displaying the modal view from my main view controller (and not from a view controllers of one of the subviews).