开发者

Orientations support

I have an app with some views, I need one view to rotate. that view is called by pushviewcontroller. all these views are inside a tabbarcontroller.

I already edit the info.plist to support orientations I added this items to Supported interface orientations: Landscape (left home button) Landscape (right home button)

and also added this to the view i want to rotate

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

but it doesnt work.

wha开发者_开发问答t do i need to do? Thanks


UITabBarController have a some problem. the problems is a subviews(selected index) not autorotate.

So, you can make a category, and add a below code.

and, add a #import "UITabBarController+Autorotate.h"

#import <Foundation/Foundation.h>


@interface UITabBarController (Autorotate)

@end

#import "UITabBarController+Autorotate.h"


@implementation UITabBarController (Autorotate)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    UIViewController *controller = self.selectedViewController;
    if ([controller isKindOfClass:[UINavigationController class]])
        controller = [(UINavigationController *)controller visibleViewController];
    return [controller shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜