问题描述
我在发布会上阅读了一些不同的文章,但是我仍然不确定它是如何工作的.我们仅支持横向定位.在didFinishLaunchingWithOptions中,我这样做:
I read a few different posts on the orientation on launch, but I'm still unsure how it works. We are only supporting landscape orientation. In didFinishLaunchingWithOptions, I do:
HomeController *myHome = [[HomeController alloc] initWithNibName:@"HomeController" bundle:nil];
myHome.navigationItem.title = @"Your Dashboard";
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myHome];
[myHome release];
self.navigationController = navController;
[navController release];
self.window.rootViewController = self.navigationController;
在我的HomeController类中:
In my HomeController class:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
但是当我在设备上启动该应用程序时,它可以颠倒地启动.我如何避免这种情况发生?我看到有人在didFinishLaunchingWithOptions中检测状态栏方向的帖子.如果我在 self.window.rootViewController = self.navigationController;
代码之后执行此操作:
When I start the app however on the device, it can start upside down. How do I avoid that from happening? I saw some posts on people detecting for the status bar orientation in didFinishLaunchingWithOptions. If I do this after the self.window.rootViewController = self.navigationController;
code:
NSLog(@"%i", [UIApplication sharedApplication].statusBarOrientation);
我总是得到3.从那里,我不确定该如何解决颠倒的问题.谢谢.
I always get 3. From there, I'm not sure what I can do to fix the upside down issue. Thanks.
推荐答案
我认为您需要在Info.plist中指定受支持的方向.请参阅Info.plist中的支持的接口配置
和支持的接口配置(iPad)
.
I think you need to specify the supported orientations in your Info.plist. See the Supported interface configurations
and Supported interface configurations (iPad)
in your Info.plist.
这篇关于iPad的启动方向与横向方向不正确(上下颠倒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!