开发者

UIInterfaceOrientation in UINavigationViewController

I'm having issue with auto rotating in my view which is inside a UINavitionViewController and the navigationViewcontroller is inside a tabBarViewController.

I subclassed tabBarViewController. The problem is the interfaceorientation works fine on the first view inside the tabViewController, but whenever I push to another view it doesn't work.

This is a code in subclass tabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 开发者_如何转开发{
    return YES;
    if([self.selectedViewController isKindOfClass:[UINavigationController class]]){
        return [[(UINavigationController*)self.selectedViewController visibleViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    } else {
        return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    }
}


You should have a UIViewController inside a UINavigationController inside a UITabBarController. The rotation is decided by shouldAutorotateToInterfaceOrientation: in your UIViewController. You need to override that method for every UIViewController to return the desired value, i.e., YES if you want it to rotate and NO if you don't want it to.

You shouldn't override shouldAutorotateToInterfaceOrientation: in UINavigationController or UITabBarController.


You have to override shouldAutorotateToInterfaceOrientation: in the view controllers for all the views in the tab bar.

If a view controller's shouldAutorotateToInterfaceOrientation: returns NO, then the tab bar will not rotate, even if the view is hidden at the time of the rotation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜