문제

Quick problem:

I have an UITabBarController with 2 navigation controllers [lets call them Left and Right Controller]

On the default selected Left Controller I can push a new View Controller that detects interface orientation.

On the Right Controller I can push the same View Controller but it won't detect interface orientation, or for that matter, It won't even go into the shouldAutoRotateInterface method at all T___T

Haaalp!!

If it is of any relevance, the View Contoller that I'm pushing use the hidesBottomBarWhenPushed property.

도움이 되었습니까?

해결책

does your uitabbarcontroller implement the auto rotate? any child viewcontroller that wants to implement autorotate has to have its parent implement autorotate.

다른 팁

Most likely this is your problem:

Tab bar controllers support a portrait orientation by default and do not rotate to a landscape orientation unless all of the root view controllers support such an orientation. When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation.

The solution is to override the following method on every view controller leading to your view:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
    return YES;
}

For example, instead using the default UITabBarController in IB, replace it with your own subclass containing just the method above.

I'm a bit late to the party on this, but I ran into a problem with autorotation at startup for a tab bar app I wanted always to run in portrait.

The app's plist has the necessary settings to both start in and only allow portrait mode, and all my view controllers only allow portrait mode. Yet, when I started the app holding my iPhone in landscape, the app started in portrait, but then rotated to landscape!

Rather than subclass UITabBarController, I simply overrode UITabBarController's shouldAutorotateToInterfaceOrientation: method using a category on class UITabBarController. I included this code in my app delegate:

@implementation UITabBarController(UITabBarControllerCategory)

-(BOOL)shouldAutorotateToInterfaceOrientation:
                 (UIInterfaceOrientation)toInterfaceOrientation
{
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Works beautifully, and is quite lightweight.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top