我正在尝试让我的应用在设备旋转时旋转界面,但我做不对。我已经在 plist 信息文件中添加了支持的接口,并对 shouldRotateToInterfaceOrientation 返回了 yes。
这是旋转功能的实现方式吗? 请帮忙!
这是旋转功能的实现方式吗? 请帮忙!
Item 0 Landscape (left home button)
Item 1 Landscape (right home button)
Item 2 Portrait (top home button)
Item 3 Portrait (bottom home button)
希望能对您有所帮助!
UITabBarController
,那么你需要调用它的子视图的 shouldAutoratateToInterfaceOrientation
方法。UITabViewController
的类中的 shouldAutorotateToInterfaceOrientation
方法中。[[tabBarController.viewControllers objectAtIndex:0] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
[[tabBarController.viewControllers objectAtIndex:1] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
当然,“tabBarController”必须通过IB与您的XIB文件中的UITabBarController
链接。
谢谢,
请确保您已将shouldRotateToInterfaceOrientation
添加到您想要支持不同方向的视图控制器中。它不应该放在应用程序委托中。
如果您使用标准UI元素,支持方向是很简单的,所以假设您正在使用标准UI元素,那么您走在了正确的道路上。
如果您正在使用UITabController,则所有视图必须支持相同的方向,否则它将默认为最小值(例如纵向),我认为。
此外,如果您为视图使用NIB,请确保在Interface Builder中配置视图时选中“自动调整子视图”。