0

我有另一個方向問題。但是這個非常棘手。 我的RootViewController是一個正常的NavigationController。方向風景 - >人像不工作

self.window.rootViewController = _naviController; 

裏面有另一個ViewController,我們稱之爲VC1。 VC1有一些按鈕和標籤。它就像文件夾的概述。

如果我按下一個按鈕,我來與3視圖控制器(頁)下一個視圖控制器和按鈕的另一一束(如文件夾內看圖片/內縮略圖):

Archiv *archiv = [[Archiv alloc] init]; 
[self.navigationController pushViewController:archiv animated:YES]; 
[archiv release]; 
中的loadView

firstPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 0, 768, 960)]; 
[firstPage setRootViewController:self]; 
secondPage = [[Page alloc] initViewWithFrame:CGRectMake(0, -960, 768, 960)]; 
[secondPage setRootViewController:self]; 
thirdPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 960, 768, 960)]; 
[thirdPage setRootViewController:self]; 

如果我現在上的按鈕再次點擊活動頁面推我的第三個視圖控制器(帶圖像縮放,拖動......):

Picture *pic = [[Picture alloc] initWithPicURLString:urlString]; 
[rootViewController.navigationController pushViewController:pic animated:YES]; 
[pic release]; 

使用NavigationController的BackButton,我總是可以回到以前的視圖。

一些更多的信息:

現在棘手的問題:

如果我從第2個VC切換到第3 VC,還有來自縱向更改方向爲橫向,按後退按鈕一切工作shouldAutorotateToInterfaceOrientation呼籲,幀大小和起源改變...)。 ,如果我周圍做它的其他方式,我在風景模式,從第2個VC切換到第3 VC,旋轉爲縱向,回來第2個VC與後退按鈕的狀態 - 和controllerBar是在頂部但是shouldAutorotateToInterfaceOrientation未被稱爲

請幫幫我。 $ h @ rky

回答

1

試試這個,它爲我工作:

-(void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
    [self shouldAutorotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] ]; 
} 
+0

是的,這項工作也是,但這不能回答問題爲什麼當我回到縱向方向時視圖沒有調用。無論如何,如果nodoby告訴我爲什麼這會在下週發生,我會接受答案。 – Sharky

+0

就像我承諾的接受和upvote,因爲決議比我的方式xD更聰明。 $ H @ RKY – Sharky

0

今天我得到了解決問題而不知道原因的想法。 在我的第三個VC中,我創建了一個指向第二個視圖的指針,並且自己調用了shouldAutorotateToInterfaceOrientation

但是問題仍然是一樣的:爲什麼shouldAutorotateToInterfaceOrientation沒有在描述的情況下調用?

親切的問候。$ H @ RKY

0

shouldAutorotateToInterfaceOrientation只有當用戶轉動叫,所以當你從橫向到縱向或以其他方式再查看控制器仍然景觀,所以這個解決問題,你必須破解的代碼,它的意思是,當你推查看從橫向控制器爲縱向presentViewController例如:

ListCurrentViewController *list = [self.storyboard 
    instantiateViewControllerWithIdentifier:@"ListCurrentViewController"]; 
       [self.navigationController presentViewController:list animated:NO completion:Nil]; 
       [list dismissViewControllerAnimated:NO completion:Nil]; 
       [self.navigationController pushViewController:list animated:YES]; 
在ListViewController功能

稱爲:

(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation // iOS 6 autorotation fix { return UIInterfaceOrientationPortrait; } 

,你必須爲UINavigationController的

(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return [self.visibleViewController preferredInterfaceOrientationForPresentation]; 
} 

我希望這個解決將幫助您創建類別。