仅支持纵向

发布于 2024-09-26 00:25:54 字数 429 浏览 1 评论 0原文

我的应用程序只需要支持纵向。我该怎么做呢?我尝试添加

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

and

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

但它没有帮助 - 视图无论如何都会旋转。

提前致谢!

I need to support only portrait orientation in my app. How can I do it? I have tried adding

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

and

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

But it does't help - the view rotates anyway.

Thanks in advance!

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

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

发布评论

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

评论(4

汹涌人海 2024-10-03 00:25:54

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 应返回一个 BOOL,在您的情况下为 NO

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientationshould return a BOOL which is NOin your case.

素手挽清风 2024-10-03 00:25:54

这应该是:

 -(BOOL)     shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return interfaceOrientation == UIInterfaceOrientationPortrait 
           || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
}

This should be:

 -(BOOL)     shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return interfaceOrientation == UIInterfaceOrientationPortrait 
           || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
}
○愚か者の日 2024-10-03 00:25:54

在 XCode 5 中(不确定早期版本),如果您只想在整个应用程序中支持纵向模式,请转到“项目设置”->“常规”->“部署信息”
并取消选中“颠倒”、“左方向”和“右方向”。

这可能是现在最简单的方法。

In XCode 5 (not sure about earlier versions), if you want on support portrait mode only across the whole app, go to Project Settings->General->Deployment info
and uncheck Upside Down, Orientation Left, and Orientation Right.

This is probably the easiest way to do it now.

御弟哥哥 2024-10-03 00:25:54

对于 iOS 6,似乎你也需要添加/重写这个方法,

-(BOOL)shouldAutorotate {
    return NO;
}

For iOS 6, it seems you need to add/override this method too,

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