繁体   English   中英

iPad的启动方向与横向方向不正确(上下颠倒)

[英]launch orientation of iPad is incorrect for landscape orientation (upside down)

我在发布会上阅读了一些不同的文章,但是我仍然不确定它是如何工作的。 我们仅支持横向定位。 在didFinishLaunchingWithOptions中,我这样做:

    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类中:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);    
}

但是,当我在设备上启动应用程序时,它可以颠倒地启动。 我如何避免这种情况发生? 我看到有人在didFinishLaunchingWithOptions中检测状态栏方向的帖子。 如果我在self.window.rootViewController = self.navigationController;之后执行此self.window.rootViewController = self.navigationController; 码:

NSLog(@"%i", [UIApplication sharedApplication].statusBarOrientation);

我总是得到3。从那里,我不确定该如何解决颠倒的问题。 谢谢。

我认为您需要在Info.plist中指定支持的方向。 请参阅Info.plist中的Supported interface configurationsSupported interface configurations (iPad)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM