仅支持纵向方向
问题描述:
我需要在我的应用中只支持纵向方向。我该怎么做?我曾尝试加入仅支持纵向方向
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
和
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationPortrait;
}
但它简化版,帮助 - 视图旋转反正。
在此先感谢!
答
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
应该在您的情况下返回一个BOOL,即NO
。
答
这应该是:
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
}
答
对于iOS 6,看来你需要添加/太重写此方法,
-(BOOL)shouldAutorotate {
return NO;
}
答
在Xcode 5(不知道早期版本),如果您只想在整个应用程序中支持肖像模式,请转至项目设置 - >常规 - >部署信息 ,然后取消选中颠倒,方向左侧和方向右侧。
这可能是现在最简单的方法。
这就是真正的原因。我很抱歉我的愚蠢:( – Knodel 2010-10-02 16:54:59