2012-08-01 19 views
0

我的應用程序出現問題。 我想鎖定特定視圖上的旋轉。爲此,我使用了包含兩個自定義viewController的rootviewcontroller。 我嘗試重寫我的兩個viewcontrollers shouldAutorotateToInterfaceOrientation方法,但如果我允許所有的旋轉我的rootViewController,我所有的viewcontrollers可以像我的rootviewcontroller旋轉,我不明白爲什麼。RootviewController和viewControllers旋轉

其實我使用這種配置:

RootviewController 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    //By default, i allow all rotation 
    return YES 
} 

FirstCustomviewController 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    //On my first viewController, I allow only orientation in portrait 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

但在所有情況下,允許所有旋轉(我認爲它來自RootViewController的),爲什麼我不能重寫此方法? 我能做些什麼?

感謝

+0

這樣做不是一個好習慣。 :(你應該支持所有單獨的'UIViewController'的可用方向,你推入你的應用程序......只是爲了你的用戶。:) – holex 2012-08-01 13:52:05

回答

1

RootViewController的和FirstCustomViewController關係正好推視圖或模式,有何看法?如果關係是push-view,則所有的子視圖旋轉都依賴於根視圖。

將UINavigationController視爲房屋,將UIViewControllers視爲房間。房子裏的所有房間都會像房子一樣旋轉。沒有房子和其他房間的轉動,沒有辦法改變房間。

+0

謝謝你的回答。你是真的,我不使用模態視圖,這就是爲什麼我有這個問題。隨着你的解釋,我知道爲什麼,是我的錯誤。我將使用模態視圖。非常感謝 – tryp 2012-08-01 14:02:30