IOS TabBarController中是否容許單個viewController旋轉屏幕

在AppDelegate實現方法以下:app

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    
    if ([window.rootViewController isKindOfClass:NSClassFromString(@"TabBarController")]) {
        
        UITabBarController * tabVC = (UITabBarController *)window.rootViewController;
        
        if (tabVC.selectedIndex == 0 || tabVC.selectedIndex == 1) {
            return UIInterfaceOrientationMaskAll;//這裏須要支持旋轉
        }
    }
            
    return UIInterfaceOrientationMaskPortrait;
            
}

關注新平臺:http://www.toutiao.com/m51416718261/code

關注訂閱號:從小就壞get

相關文章
相關標籤/搜索