2012-05-31 43 views

回答

1

UITabBarController有一些問題。問題是一個子視圖(選定的索引)不能自動旋轉。

因此,您可以創建一個類別,並添加下面的代碼。

,並添加#進口 「的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