开发者

programmatically creating a splitviewcontroller with two uiviewcontrollers that use navigation controllers

I would like to create a UISplitViewController programmatically and have as its master and detail controller (the left and right pane), two UIViewController subclasses which I use to handle various things like processing when cells are selected and so forth.

My problem is that I'm not certain how to create navi开发者_StackOverflowgation controllers within these custom master and detail controllers and hook them up to the splitview controller. Currently, I add my controllers like this:

mSplitViewController.viewControllers = [NSArray 
    arrayWithObjects:mSplitMasterController,mSplitDetailController, nil];

and I within each custom controller I have a container UIView created on which I can assemble my subviews. I'm not sure how I add the navigation controllers to these. Do I need to basically do something like this within my custom controllers' loadView?

[self.view addSubview:mNavigationController.view];

after constructing the controllers (and their views) that the navigation controller will manage?


You don't need UIView containers. If wanted to use containers you would need UIViewControllers. Regardless just add the navigation controller to the array directly. Later you can access them from the same array to push and pop on the other split view.

RootViewController* rootViewController = [[RootViewController alloc] init];
navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[rootViewController release];

splitVC = [[UISplitViewController alloc] init];

[window addSubview:splitVC.view];

TempViewController* tempViewController = [[TempViewController alloc] initWithNibName:@"TempViewController" bundle:nil];
detailNavController = [[UINavigationController alloc] initWithRootViewController:tempViewController];
[tempViewController release];

splitVC.viewControllers = [NSArray arrayWithObjects:navController, detailNavController, nil];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜