shouldAutorotateToInterfaceOrientation 没有被调用
我有一个横向应用程序,如果设备翻转,我想将其旋转 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];
}
I have a landscape app that I want to rotate 180 degress if the device is flipped. In my main view controller however, shouldAutorotateToInterfaceOrientation is not getting called at all. Why would that be?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
NSLog(@"ROTATE? %d", interfaceOrientation); //this never gets logged
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
EDIT: In the app delegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:topViewController.view];
[window makeKeyAndVisible];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我编辑了错误的视图控制器文件(iphone 与 ipad)。上面的代码有效。顺便说一句@ughoavgfhw,不需要编辑 info.plist 就可以发生这种情况。
Sorry, I was editing the wrong view controller file (iphone vs ipad). The code above works. BTW @ughoavgfhw, editing the info.plist isn't necessary for this to happen.