【发布时间】: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