iPhone Dev - 保持界面旋转
(正如你所知,我正在学习在没有 Interface Builder 的情况下为 iPhone 进行开发) 我有一个带有根视图控制器、蓝色视图控制器和黄色视图控制器的应用程序。 根 VC 延迟加载蓝色和黄色 VC,并首先显示蓝色 VC 的视图,然后在按下底部工具栏中的按钮时切换到另一个视图。 我设置了所有的 autoresizingMasks,所以它们旋转得很好,但是如果说正在显示蓝色视图,我旋转到横向,它很好,但是当我切换视图时,黄色视图就一团糟了,因为它从不自动旋转,它从纵向尺寸开始,然后自动旋转到横向视图,但是当它将正常的纵向黄色视图加载到横向视图中时,一切都搞砸了,黄色视图永远不会与其余视图一起自动旋转,因为它没有即使在视图中作为子视图。 那么我该如何解决这个问题呢? 有什么方法可以让它初始化,就好像它已经自动旋转(如果确实需要的话)?
谢谢!!
(Just so you know ,I'm learning to develop for iPhone without Interface Builder)
I have an app with a root view controller, a blue view controller and yellow view controller. The root VC lazy-loads the blue and yellow VC's and displays the blue VC's view first, and then switches to the other one when a button in the toolbar at the bottom is pressed. I have all the autoresizingMasks set, so they rotate fine, but if say the blue view is being displayed, I rotate to landscape, its fine, but then when I switch views the yellow one is all messed up because its never auto-rotated, it starts out with portrait dimensions, and auto-rotates to landscape fine, but when it loads the normal portrait yellow view into the landscape view, everything is messed up, the yellow view never got auto-rotated with the rest because it wasn't even in view as a subview. So how can I fix this? Is there some way I can make it initialize as if it had already auto-rotated if it does need to be?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过为视图控制器创建 initPortrait 和 initLandscape 初始化方法解决了这个问题,只需执行常规 init 并将 isPortrait BOOL 设置为 YES 或 NO,然后在视图加载中,我根据 isPortrait 的值设置不同的框架。
I solved this by making a initPortrait and initLandscape initialization methods for the view controllers, that just do a regular init and set the isPortrait BOOL to YES or NO, and then in view did load I set the frame differently depending on the value of isPortrait.