【问题标题】:shouldAutorotateToInterfaceOrientation not getting calledshouldAutorotateToInterfaceOrientation 没有被调用
【发布时间】:2011-03-26 00:07:29
【问题描述】:

我有一个横向应用程序,如果设备翻转,我想旋转 180 度。然而,在我的主视图控制器中,shouldAutorotateToInterfaceOrientation 根本没有被调用。为什么会这样?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    NSLog(@"ROTATE? %d", interfaceOrientation); //this never gets logged
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

编辑:在应用委托中:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    [window addSubview:topViewController.view];
    [window makeKeyAndVisible];

}

【问题讨论】:

  • 您是否在窗口中添加了多个控制器的视图?见这里:developer.apple.com/library/ios/#qa/qa1688/_index.html(技术问答 QA1688 为什么我的 UIViewController 不能随设备旋转?)
  • 没有。我将编辑帖子以显示应用程序委托。
  • 您是否编辑过 Info.plist 文件以显示它支持这两种方向?

标签: ios uiviewcontroller orientation


【解决方案1】:

抱歉,我编辑了错误的视图控制器文件(iphone vs ipad)。上面的代码有效。顺便说一句 @ughoavgfhw,编辑 info.plist 不是必要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多