I have a VC in Portrait which presents another VC that can either be portrait or landscape. The problem is that when I return back to the original VC that presented it, it is also shown in landscape until I rotate it and then it stays in portrait. What I want is to always have the original VC to always be portrait, how can I achieve this? Here it the code that I use to set up the VC orientations after I have set the supported orientations in my PList:
In the original VC, that should always be portrait
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
In my VC that could either be portrait or landscape, I have:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
Override the supportedInterfaceOrientations method and return UIInterfaceOrientationMaskPortraitUpsideDown.
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.