I have this code which works fine except for if you enter the view controller from portrait then it stays in portrait. I need it once it goes to the view controller to go to landscape and stay in landscape.
- (NSUInteger)supportedInterfaceOrientations {
if (self.isFlexiGram) {
return UIInterfaceOrientationMaskLandscape;
} else {
return UIInterfaceOrientationMaskAll;
}
}
- (BOOL)shouldAutorotate {
return YES;
}
I'm changing my container view controller with the following methods
#pragma mark - Container Controller Methods
- (void)presentDetailController:(UIViewController*)detailVC{
//0. Remove the current Detail View Controller showed
if(self.currentDetailViewController){
[self removeCurrentDetailViewController];
}
//1. Add the detail controller as child of the container
[self addChildViewController:detailVC];
//2. Define the detail controller's view size
detailVC.view.frame = [self frameForDetailController];
//3. Add the Detail controller's view to the Container's detail view and save a reference to the detail View Controller
[self.containerView addSubview:detailVC.view];
self.currentDetailViewController = detailVC;
//4. Complete the add flow calling the function didMoveToParentViewController
[detailVC didMoveToParentViewController:self];
}
- (void)removeCurrentDetailViewController{
//1. Call the willMoveToParentViewController with nil
// This is the last method where your detailViewController can perform some operations before neing removed
[self.currentDetailViewController willMoveToParentViewController:nil];
//2. Remove the DetailViewController's view from the Container
[self.currentDetailViewController.view removeFromSuperview];
//3. Update the hierarchy"
// Automatically the method didMoveToParentViewController: will be called on the detailViewController)
[self.currentDetailViewController removeFromParentViewController];
}
I've tried the preferredInterfaceOrientationForPresentation but that doesn't get called because I'm not using presentViewController.
I've tried the following questions
Forcing UIInterfaceOrientation changes on iPhone IOS 6 force device orientation to landscape
I've also gone through apple documentation