如果从另一个视图返回,则不会调用 willRotateToInterfaceOrientation 方法
我在 iPhone 中处理设备方向时遇到了很多麻烦。当设备方向更改时,我必须添加/删除隐藏/取消隐藏,特别是导航控制器的工具栏
场景:
[纵向设备]。
DetailViewController 启动..根据横向或纵向方向设置其视图。 (现在是肖像)在 willRotateToInterfaceOrientation 方法中。
点击按钮后,视图将被推送到 NewViewController。它还支持纵向和横向。现在设备在 NewViewController 中变成了横向。一切都很好。 问题在于,当点击“返回”到 DetailViewController(最后一次在纵向中看到)时,在横向时不会进行隐藏/取消隐藏更改。因为, willRotateToInterface 根本没有被调用。在“ViewWillAppear”中添加功能并不是一个好方法。
重述一下: DetailVeiwController(肖像) -->推——> NewViewController(Portrait) --> 旋转 --> NewVewController(横向) --->向后推-->DetailViewController(横向)(在 DetailViewController 中未调用 willRotate。
在这种情况下,正确的前进方式是什么?正确的方式。具有最小的内存占用。
谢谢:)
Im running into alot of trouble just handling the device orientation in iPhone. I have to Add/Remove Hide/Unhide particularly the NavigationController's toolBar when the Device Orientation is changed
The scenario:
[Device in Portrait].
DetailViewController starts.. sets its view according to the orientation either Landscape or Portrait. (Now Portrait) in willRotateToInterfaceOrientation method.
Upon tapping a button, View is Pushed to a NewViewController. That also supports both portrait and Landscape. Now the device is turned to Landscape in NewViewController. Everythings fine.
Heres the Problem, when tapping "Back" to DetailViewController (which was last seen in Portrait) doesnt make those hide/unhide changes when its in Landscape. Because, willRotateToInterface is not called at all. And its kinda not a good way to add a function in "ViewWillAppear".
to recape:
DetailVeiwController(Portrait) --> PUSHED --> NewViewController(Portrait) -->Rotate--> NewVewController(Landscape) ---> PUSHED BACK-->DetailViewController (Landscape) (willRotate is not called in DetailViewController.
In such a case, whats the right way forward?? the right way. with minimum memory footprint.
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅如何处理旋转一个不在 UINavigationController 堆栈顶部的 UIViewController ?...
See How to handle rotation for a UIViewController that isnt on top of UINavigationController stack ?...