2012-03-02 62 views
0

我想我的应用程序支持PortraitUpSideDown方向。 我已经改变了info.p名单,以反映这一点,并试图执行一个视图改变为测试UIInterfaceOrientation Xcode

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    return YES; 
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
    return YES; 

} 

但鉴于没有响应。 在应用程序响应之前,我是否需要在所有视图上实现此功能? 是否有需要更改的Xib设置?

+0

这不是一个Xcode问题。这是一个____问题,你用你正在使用的显示库来填充空白。 – Almo 2012-03-02 19:49:33

回答

5

如果你想同时支持横向模式,请尝试以下操作:

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

或者:

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

或者出头,看起来像你试图写:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (interfaceOrientation == UIInterfaceOrientationPortrait) { 
     return YES; 
    } 
    if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     return YES; 
    } 
    return NO; 
} 
+0

+1第二个片段更清洁:) – dasblinkenlight 2012-03-02 19:52:58

+0

感谢sch为这些解决方案应用程序似乎没有回应它是一个标签栏应用程序也许这与它有什么关系? – MacUser 2012-03-02 20:36:56

+0

@sch最后一段代码片段在苹果论坛中与以下解决方案配合使用:https://discussions.apple.com/message/8544354#8544354 感谢您的帮助! – MacUser 2012-03-02 21:27:30

相关问题