I am having trouble performing an unwind segue to the previous view controller while preserving the previous view controllers preferred orientation. I have implemented categories in the tabbarcontroller, navcontroller, and various view controllers to override rotation methods, and aside from this one issue, these controllers maintain the supported views.
I have created a button on the modal view controller that unwinds to the previous controller. When I press this button while in landscape, it unwinds to the previous, but in landscape, although the viewcontroller's preferred/supported orientation is portrait.
I would like to perform this unwind segue while not allowing it to display the controller as landscape (segue's back to portrait). I have included a short video showing my problem.
https://www.dropbox.com/s/a5epj9tpmk85cnv/segueproblem.mov
TabBarController.m
@implementation UITabBarController (autoRotate)
- (BOOL)shouldAutorotate {
return [self.selectedViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.selectedViewController supportedInterfaceOrientations];
}
NavController.m
@implementation UINavigationController (autoRotate)
- (BOOL)shouldAutorotate {
return [self.visibleViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.visibleViewController supportedInterfaceOrientations];
}
BViewController.m
@implementation BViewController
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
- (IBAction)unwindToViewControllerNameHere:(UIStoryboardSegue *)segue {
}
CViewController.m
@implementation CViewController
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (IBAction)backbutton:(id)sender {
}