仅使用一个 ViewController 从 XIB 切换
我正在尝试创建一个可以在纵向和横向模式下工作的应用程序,并且只有一个 ViewController。 所以我有 2 个文件 XIB...我如何从 ViewController 中选择其中之一? 我已经找到了如何检查设备是否处于纵向或横向模式,但我无法在 2 个 XIB 之间切换...:(
请帮助我!谢谢!
i'm trying to crete an App that works in potrait and landscape mode, with ONLY ONE ViewController.
So i've 2 file XIB... how can i select one of them from the ViewController?
I've already found how to check if the device is in potrait or landscape mode but i can't switch between the 2 XIBs... :(
Please help me! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该对同一视图使用不同的 XIB。相反,请正确操作视图或设置自动调整大小蒙版。
You should not use different XIBs for the same view. Instead, manipulate the view or set your autoresize masks correctly.
您可以使用一个具有两个视图的笔尖,一个纵向视图和一个横向视图。您还需要拥有的每个 IBOutlet 中的两个(每个方向一个),然后像往常一样进行设置。然后,当您需要旋转时,将 self.view 替换为您要旋转到的视图,并根据需要设置出口。
然而,如果视图很简单,有效地使用自动调整大小子掩码可能是更好、更简单的选择。
You can use one nib that has two views, a portraitView and a landscapeView. You would also need two of every IBOutlet you have (one for each orientation) and then set them up as usual. then when you need to rotate, replace self.view with the view you are rotating to, and set the outlets as necessary.
If the view is simple, however, using the autoresizing submasks effectively may be a better, simpler option.