我有消息應用程序例如WhatsApp & ...... 這樣的層次:防止改變方向的視圖 - 控制
Tab Bar Controller
Navigation Controller
View Controller
Target Controller
,所以我們打算從的appDelegate
UITabBarController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"mainTab"];
self.window.rootViewController = ivc;
[self.window makeKeyAndVisible];
的TabBar這樣我的問題 我想在某個條件下鎖定方向目標控制器 但-(BOOL)shouldAutorotate
supportedInterfaceOrientations
不叫,我已閱讀了一些關於這個帖子,但我找不到正確的解決方案。 的帖子是這樣的:多小時搜索 Lock Screen Rotation in iOS 8
Handling autorotation for one view controller in iOS7
UPDATE
後,我找到了解決辦法,但還不夠 此鏈接暗示對我來說,如果我們使用UITabController每事情會改變,所以我們應該打電話
-(NSUInteger)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController
{
return navigationController.topViewController.supportedInterfaceOrientations;
}
-(NSUInteger)tabBarControllerSupportedInterfaceOrientations:(UITabBarController *)tabBarController
{
return ((parentOfTarget*)[tabBarController.viewControllers objectAtIndex:0]).supportedInterfaceOrientations;
}
這個原因我通知改變方向&阻止它,但我會看到狀態欄的方向。
我想我需要調用
navigationController.topViewController.shouldAutorotate;
但它是導致死機;(
TabBarController: Orienting views in different orientations
它棄用&也在我的視圖控制器 – Mohamad
不叫我知道它的過時,但它的工作......好吧,你可以看到我的更新,回答這個查詢 –
沒有工作,它與UINavigationController的 – Mohamad