i have a tabbar ios app. i want to make one of the tabs portrait only. how do i do that? i already tried the solution in How to force view controller orientation in iOS 8? and didn't help. I put that in view controller's .m code. This view controller has both a UIView and UITableView in it. pl see image below;
thank you.
in your all viewcontroler write this code:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll; //allow rotate landscape, portrait
}
and write this code in in which viewconroller you want only portrait.
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown; // portrait only
}
OR you can use this one:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([self.window.rootViewController.presentedViewController isKindOfClass: [CompareViewController class]])
{
CompareViewController *compareController = (CompareViewController *) self.window.rootViewController.presentedViewController;
if (compareController.isPresented)
return UIInterfaceOrientationMaskLandscape;
else return UIInterfaceOrientationMaskPortrait;
}
else return UIInterfaceOrientationMaskPortrait;
}