UISplitView show different views in the detail pane
How can I change the view in the Details pane of the UISplitView
so that its a completely different view?
Im having a fair amount of trouble understanding how its all wired up and where things should go at the moment, could someone please enlighten me?
What I would 开发者_高级运维love to be able to do is to show a specific view based on what the user has selected in the UITableView on the left pane (this view could be an image, or a more complex view of a news article, etc... many different options) then when the user turns the iPad into portrait view, that view that was in the details pane changes to be its equivalent portrait view version.
Does this make sense?
How on earth would I do that?
Just to brainstorm, here is what I was thinking:
- Create a Split View project
Create 2 NIBs for each view: (with accompanying view controllers???)
- PortraitNewsStory
- LandscapeNewsStory
- PortraitImageBrowser
- LandscapeImageBrowser
etc...
Create a UISplitView control using XCode
Capture when a user rotates the iPad (should this be done in the
RootViewController.m
?)Change the
view
of theDetailViewController
how should I do this?profit???
Thanks Mark
you can create split view programmitically and add view controller in viewcontroller array of UISplit view . So changing view controller in split view is possible.
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewController=[[FirstDetailViewController alloc]init];
UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];
self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
self.splitViewController.delegate=self.detailViewController;
and to change view controller you have to setViewControllers to UISplitView
you can check out the example here http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/
Change the view of the DetailViewController how should I do this?
In Simple, you can make another UIViewController (ex named as MyCostomViewController) with corresponding nib file. Then do the following inside the method under rootViewController
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/*
When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
*/
//detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
MyCostomViewController *cus = [[MyCostomViewController alloc] initWithNibName:@"MyCostomViewController" bundle:nil];
[detailViewController.view addSubview:cus.view];
}
精彩评论