2010-09-09 26 views
1

我有一個tabBarViewController,當在標籤0中,用戶能夠水平地轉動設備並且顯示landscapeViewController。在橫向視圖控制器中,我需要能夠使用按鈕加載不同的全屏視圖,具體取決於用戶希望看到的內容。它適用於某一點,但隨後會混淆。基本上,當用戶第一次旋轉視圖加載正確,但然後當viewController試圖加載第二個橫向視圖它不重新定位在這個視圖中的元素,只有狀態欄?如果我然後旋轉到其他景觀設計,它會自行排列?有誰知道我做錯了什麼?UIOrientation加載查看錯誤的方式

下面是我的一些代碼

-(void)viewWillAppear:(BOOL)animated { 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; 
} 

-(void)detectOrientation { 
    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) 
     [delegate landscapeViewController:self didRotateBack:YES]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

-(IBAction)showSecondLandscapeView { 
    self.view = secondLandscapeView; 
} 

非常感謝

編輯:我還應該提到的是,landscapeViewController正在呈現模態,不知道這有什麼差別,雖然。

回答

0

好的,結果是,如果我改變self.view = secondView到[self.view addSubview:secondView]它的工作原理。