2013-07-21 42 views
0

我的iOS應用程序是以縱向格式構建的,我想保留它。然而,有一個屏幕,我想只在橫向,而不是肖像,但不知道如何去做。製作1個UIViewController橫向模式

有什麼可以建議的嗎?

非常感謝

回答

0

首先,你應該建立在Xcode項目概要支持的接口方向的所有方向。然後在您的appDelegate:

- (NSUInteger) application: (UIApplication*) application supportedInterfaceOrientationsForWindow: (UIWindow*) window 
{ 
    NSUInteger orientations = UIInterfaceOrientationMaskAll; 

    if (self.window.rootViewController) 
    { 
     UIViewController* rootViewController = self.window.rootViewController; 
     UIViewController* presented; 

     if ([rootViewController isKindOfClass: [UINavigationController class]]) 
     { 
      presented = [[(UINavigationController*) rootViewController viewControllers] lastObject]; 
     } 
     else 
     { 
      presented = (UIViewController*) rootViewController; 
     } 

     orientations = [presented supportedInterfaceOrientations]; 
    } 

    return orientations; 
} 

然後在每個UIViewController中:

- (NSUInteger) supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

中,你需要,你應該從UIInterfaceOrientationMaskPortrait改變UIInterfaceOrientationMaskLandscapeLeft或其它其它的方向。

+0

謝謝 - 我添加了代碼,但它似乎沒有什麼區別。我允許在界面中的所有方向總結,然後按照你說的添加,但沒有工作......缺少什麼? – Omar

+0

我創建了示例項目。你可以檢查它https://github.com/SKrotkih/TestRotations – stosha