I have messaging app like whatsapp & ... The hierarchy like this :
Tab Bar Controller
Navigation Controller
View Controller
Target Controller
so we are going to Tabbar like this from appDelegate
UITabBarController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"mainTab"];
self.window.rootViewController = ivc;
[self.window makeKeyAndVisible];
my problem
I want to lock the orientation in some condition in a Target Controller
but -(BOOL)shouldAutorotate
supportedInterfaceOrientations
doesn't call , i have read some post about this but i can't find the correct solution.
the posts like this :
Lock Screen Rotation in iOS 8
Handling autorotation for one view controller in iOS7
UPDATE
after many hour for searching , i found the solution but it's not enough this link hint to me , if we use UITabController every thing will change so , we should call
-(NSUInteger)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController
{
return navigationController.topViewController.supportedInterfaceOrientations;
}
-(NSUInteger)tabBarControllerSupportedInterfaceOrientations:(UITabBarController *)tabBarController
{
return ((parentOfTarget*)[tabBarController.viewControllers objectAtIndex:0]).supportedInterfaceOrientations;
}
this cause i give notification of change orientation & prevent it, but i will see orientation of status bar .
i think i need to call
navigationController.topViewController.shouldAutorotate;
but it's cause crash ;(