2014-05-20 44 views
2

如果我設置一個觀景臺控制器作爲AppDelegate中窗口的根控制器,當應用程序在iPad上橫向啓動,該中心視圖顯示在它的縱向方向的大小,而不是調整到景觀。問題在景觀與IIViewDeckController開始爲RootController在iPad上

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    IIViewDeckContoller *rootController = [IIViewDeckController new]; 

    self.window.rootViewController = rootController; 
    self.window.backgroundColor = [UIColor blackColor]; 

    [self.window makeKeyAndVisible]; 
} 

但是,如果我創建一個簡單的控制器作爲根控制器,然後呈現來自該根控制器視圖甲板控制器,然後一切似乎顯示就好了。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    UIViewController *simpleRootController = [UIViewController new]; 
    IIViewDeckContoller *deckController = [IIViewDeckController new]; 

    self.window.rootViewController = simpleRootController; 
    self.window.backgroundColor = [UIColor blackColor]; 

    [self.window makeKeyAndVisible]; 

    // View Deck Controller seems to have issues when it is the root controller of the main window. 
    // Presenting it as a modal seems to do the trick. 
    [simpleRootController presentViewController:self.deckController animated:NO completion:nil]; 
} 

其他人遇到這個問題?有沒有更好的方法來解決這個問題?我沒有看到與iPhone相同的行爲。

回答

0

我見過具有IIViewDeckController下面的方法成功的一些人:

- (CGRect) referenceBounds { 
    if (self.referenceView) { 
     return self.referenceView.bounds; 
    } 
    CGRect bounds = [[UIScreen mainScreen] bounds]; // portrait bounds 
    if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { 
     bounds.size = CGSizeMake(bounds.size.height, bounds.size.width); 
    } 
    return bounds; 
} 

不過,我沒有看到任何改變。由於其他限制,我不能接受OP提出的視圖控制器的建議。