在iPhone SDK中删除应用程序纵向方向的功能

时间:2010-07-04 23:33:11

标签: iphone xcode ipad orientation

有没有办法让我的应用只能在横向模式下观看?我已经设法将应用程序的方向默认为横向,但是在iPad模拟器中,当我执行Command-> Arrow时,应用程序将旋转为纵向。我在两个肖像条目的“支持的界面方向”下删除了plist中的列表,但这似乎没有改变任何内容。

有什么想法吗?

5 个答案:

答案 0 :(得分:11)

在视图控制器中,有一个委托方法:

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

答案 1 :(得分:3)

项目是否找到“autorotate”,并编辑相应的方法。

答案 2 :(得分:1)

答案 3 :(得分:1)

实际上是

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

答案 4 :(得分:0)

事情随着一些更新而改变。目前,您只需添加以下方法:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

只会允许风景。转动你喜欢的手机,它只会留在左右两侧。玩得开心:))