gpt4 book ai didi

ios - shouldAutorotateToInterfaceOrientation 没有被调用

转载 作者:行者123 更新时间:2023-11-28 17:46:48 24 4
gpt4 key购买 nike

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

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

编辑:在应用委托(delegate)中:

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

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

}

最佳答案

抱歉,我编辑了错误的 View Controller 文件(iphone vs ipad)。上面的代码有效。顺便说一句@ughoavgfhw,编辑 info.plist 并不是发生这种情况所必需的。

关于ios - shouldAutorotateToInterfaceOrientation 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5439388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com