简体   繁体   中英

UIView Orientation in UINavigationController in IOS6

I have a UINavigation base app in which I was supporting all orientations for some view controller but not for all using this code

@interface UINavigationController (Autorotation)

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; @end

    @implementation UINavigationController (Autorotation)

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{

if ([self.visibleViewController isKindOfClass:[MWPhotoBrowser class]] || [self.visibleViewController isKindOfClass:[ZoomPictureViewController class]]) { return YES; } return (toInterfaceOrientation == UIInterfaceOrientationPortrait); } @end

It was working great but not working in IOS6. I have set all four orientations supported in my projects plist file.

Help if anyone has found some work around for.

In ios 6 there are new methods for orientation use these methods in your navigation controller subclass

-(BOOL) shouldAutorotate
{
return YES;
}

-(NSUInteger) supportedInterfaceOrientations{
if ([self.visibleViewController isKindOfClass:[YourClass class]] ||[self.visibleViewController isKindOfClass:[YourClass class]]) {
return UIInterfaceOrientationMaskAll;
}

return UIInterfaceOrientationMaskPortrait;
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM