2012-12-06 35 views
0

正在使用iOS6設備xcode 4.5 &山獅子mac。 並在我的應用程序開始在肖像模式(3屏幕)。 但第4屏幕應在景觀,並應支持景觀左&景觀權。在iOS6中的橫向模式中的應用程序

大多數解釋都顯示如何旋轉。

在appddelegate

正在使用

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
     UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 
navigationController.navigationBar.tintColor = [UIColor blackColor]; 


// Set RootViewController to window 
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0) 
{ 
    // warning: addSubView doesn't work on iOS6 
    [self.window addSubview: navigationController.view]; 
} 
else 
{ 
    // use this mehod on ios6 
    [self.window setRootViewController:navigationController]; 
} 

} 
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    if(self.shouldRotate) //shouldRotate is my flag 
    { 
     self.shouldRotate = NO; 
     return (UIInterfaceOrientationMaskLandscapeRight); 
    } 
    return (UIInterfaceOrientationMaskPortrait); 
} 

,並在我的視圖控制器這應該是景觀和正在使用

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) 
    { 
     appDelegate.shouldRotate = YES; 
     // Custom initialization 
    } 
    return self; 
} 



- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
     return UIInterfaceOrientationMaskLandscape; 
} 

在我viewcontrollers這是potrait都正常工作,其中正在使用

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
     return UIInterfaceOrientationMaskPortrait; 
} 

任何人都可以提出這樣做​​

在此先感謝

+0

的'[self.window setRootViewController:navigationController ]'應該在iOS 4及更高版本上調用,所以只需刪除iOS 6的檢查,並一直使用'self.window.rootViewController'屬性。 – rckoenes

+0

只需投入我的兩分錢,支持風景的應用程序就能支持整個應用程序的景觀。您不應該強迫用戶在工作流程中間輪換設備。 –

+0

self.window.rootViewController = navigationController;通過使用這一個也不加載景觀景觀 –

回答

0

這是爲我工作 我刪除NavigationController,改變如下

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    { 
     self.viewController = [[PlashViewController alloc] initWithNibName:@"PlashViewController" bundle:nil]; 
    } 
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

IM我的應用我擺在我的視圖控制器這種方法如下 和plist中和目標我指定了三個方向,如縱向,橫向和縱向 以顯示縱向視圖

-(BOOL)shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

在橫向顯示視圖

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
} 
相關問題