UISplitViewController in a TabBar ( UITabBarController )?

前端 未结 9 846
长发绾君心
长发绾君心 2020-11-30 19:35

I am in kind of situation that I need to start with a tab based application and in that I need a split view for one or more tabs. But it seems that split view controller obj

相关标签:
9条回答
  • 2020-11-30 20:17

    We succeeded in having a UISplitViewController inside a UITabViewController on iPad with iOS5+.

    to make a long story short: it works:

    • out of the box if you accept a split also in portrait;
    • with a bit of work, if you want to have the master view hidden in portrait, and have it appear only upon tapping a button.

    The trick in the second case is to use the IntelligentSplitViewController (see a few posts up, thanx Greg Combs) or similarly extend a UISplitVC, and be careful that the delegate of the subclass of the splitview controller is always a live object.

    We have detailed the process on:

    https://devforums.apple.com/message/763572#763572

    0 讨论(0)
  • 2020-11-30 20:18

    I made a sample application. and found we can do it programmatically like:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
            NSMutableArray *array = [NSMutableArray array];
    
            NSMutableArray *tabArray = [NSMutableArray array]; 
    
            UISplitViewController *splitViewConntroller = [[UISplitViewController alloc] init];
    
            MainViewController *viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
            [array addObject:viewCont];
            [viewCont release];
    
            viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
            [array addObject:viewCont];
            [viewCont release];
    
    
    
    
            [splitViewConntroller setViewControllers:array];
    
            [tabArray addObject:splitViewConntroller];
    
            [splitViewConntroller release];
    
            array = [NSMutableArray array];
    
            splitViewConntroller = [[UISplitViewController alloc] init];
    
            viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
            [array addObject:viewCont];
            [viewCont release];
    
            viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
            [array addObject:viewCont];
            [viewCont release];
    
            [splitViewConntroller setViewControllers:array];
    
            [tabArray addObject:splitViewConntroller];
    
            [splitViewConntroller release];
    
            // Add the tab bar controller's current view as a subview of the window
            [tabBarController setViewControllers:tabArray];
    
            [window addSubview:tabBarController.view];
            [window makeKeyAndVisible];
    
            return YES;
        }
    

    Hope this helps.

    0 讨论(0)
  • 2020-11-30 20:19

    See my post about retrofitting split view controllers to an existing tab bar interface: http://markivsblog.blogspot.com/2010/04/retrofitting-ipad-uisplitviewcontroller.html

    0 讨论(0)
提交回复
热议问题