我想創建一個帶有主視圖控制器和詳細視圖控制器的UINavigationController。不同方向的UINavigation控制器
主視圖控制器可以在Portrait和LandscapeRight中旋轉,而詳細視圖控制器只能在LandscapeRight中查看(詳細信息顯示電影)。
設置它的最佳方法是什麼?
我想創建一個帶有主視圖控制器和詳細視圖控制器的UINavigationController。不同方向的UINavigation控制器
主視圖控制器可以在Portrait和LandscapeRight中旋轉,而詳細視圖控制器只能在LandscapeRight中查看(詳細信息顯示電影)。
設置它的最佳方法是什麼?
我會建議添加的代碼
以下線在您的主視圖控制器:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
,並在您的詳細視圖控制器
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
這應該做的伎倆。
在IOS 7,該方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
已被棄用。但您可以使用
- (BOOL)shouldAutorotate
只需返回yes/no。
,然後你可以告訴視圖 - 控制其方向是可以接受的
- (NSUInteger)supportedInterfaceOrientations
哦,乖乖,如果只有它是那麼簡單。 – cannyboy 2012-02-14 18:53:07