在横向启动导航控制器?
我正在尝试制作一个使用导航控制器的横向应用程序,但我无法让该应用程序以横向模式启动。一旦我在另一个视图中,我使用 [self.navigation popToRootViewControllerAnimated:YES];那么根视图是横向的。为什么应用程序启动后它不是横向的。
我已经在 Interface Builder 中将其置于横向模式,并且已经实现了以下代码。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
有人可以向我解释一下吗?我应该在应用程序委托中做一些事情吗?
I'm trying to make a landscape app that uses navigation controller, but I can't get the app to launch in lanscape mode. Once I'm in another view and I use [self.navigation popToRootViewControllerAnimated:YES]; then the root view is in landscape. Why isn't it in landscape from the launch of the app.
I've already put it in landscape mode in Interface Builder and I've already implemented the following code.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Can someone please explain this to me. Am I supposed to be doing something in the appdelegate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 Info.plist 密钥参考。特别是,将
<数组>
<字符串>UIInterfaceOrientationLandscapeRight <字符串>UIInterfaceOrientationLandscapeLeft
第二个允许您的应用程序在两个方向启动,但仅在 OS 3.2+ 上受支持,因此您可能还想包含第一个。对于仅横向应用程序,“LandscapeRight”似乎比“LandscapeLeft”更常见。
See the Info.plist key reference. In particular, set either
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeLeft</string> </array>
The second one lets your app start up in both orientations, but is only supported on OS 3.2+, so you probably want to include the first one as well. "LandscapeRight" seems more common than "LandscapeLeft" for landscape-only apps.
尝试在应用程序的 plist 中添加键值对“支持的界面方向”。
try adding the key-value pair 'supported interface orientations' in the plist of the application.