shouldAutorotateToInterfaceOrientation 没有被调用

发布于 2024-10-26 16:27:28 字数 689 浏览 3 评论 0原文

我有一个横向应用程序,如果设备翻转,我想将其旋转 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后咖啡店 2024-11-02 16:27:28

抱歉,我编辑了错误的视图控制器文件(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文