仅支持纵向
我的应用程序只需要支持纵向。我该怎么做呢?我尝试添加
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
应返回一个 BOOL,在您的情况下为NO
。-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
should return a BOOL which isNO
in your case.这应该是:
This should be:
在 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.
对于 iOS 6,似乎你也需要添加/重写这个方法,
For iOS 6, it seems you need to add/override this method too,