2010-08-19 56 views
0

我有一款应用程序,它是一款游戏,它不适合在横向上使用。iPad上的UIInterfaceOrentation

现在我的代码是:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Overriden to allow any orientation. 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 

}

并允许只在画像(上底部home键)上运行,我希望它在纵向的(Home键上运行底部或顶部),所以苹果接受它。

我曾尝试:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

,并没有工作...... 能有人给我的代码,以便它在纵向模式下运行,使之。

回答

0

您只能返回一次,所以第二个返回语句永远不会被评估。使其成为一个布尔OR:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) || (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

也有纵向和横向的宏,但这应该工作得很好。