禁用纵向模式

发布于 2024-12-22 05:50:29 字数 136 浏览 1 评论 0原文

我正在开发 iPhone 应用程序,该应用程序只能在横向模式下运行。但是,当我旋转设备或模拟器时,viewContoller 的模式从横向变为纵向。我希望 viewController 保持横向模式,尽管设备或模拟器是纵向的。我怎样才能做到这一点?提前致谢。

I am developing an iPhone application and the application should work only in landscape mode. But, when I rotate the device or simulator, the viewContoller's mode changes from landscape to portrait. I want the viewController to maintain in landscape mode, though the device or simulator is portrait. How could I make this happen? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

单挑你×的.吻 2024-12-29 05:50:29

在视图控制器中重写此方法:

// Override to allow orientations other than the default portrait orientation.
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientation, NO for other;
}

Override this method in your view controller:

// Override to allow orientations other than the default portrait orientation.
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientation, NO for other;
}
疑心病 2024-12-29 05:50:29

将其添加到您的 ViewController.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);   
}

Add this to your ViewController.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);   
}
〃安静 2024-12-29 05:50:29

info_plist 中的更改..
支持的界面方向 仅设置横向

change in info_plist ..
Supported interface orientations Set only landscape

何以心动 2024-12-29 05:50:29

在所有 ViewController 中覆盖此方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

另请参阅仅支持横向界面方向

Override this method in all your ViewControllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

And also see Only support for landscape Interface orientation

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