Reusable Detail View Controller for UISplitViewController?
Reusable Detail View Controller for UISplitViewController?
- Subject: Reusable Detail View Controller for UISplitViewController?
- From: Steve Mykytyn <email@hidden>
- Date: Fri, 31 Jul 2015 12:56:37 -0700
This seems too easy - seems to work great. Can anyone point out a defect
with this approach?
I want to reuse the same view controller instance as the detail view
controller for a UISplitViewController - my experience is that constantly
instantiating view controllers can be sluggish.
Simply making the persistent view controller a child controller of the
newly instantiated detail view controller seems to work just fine, as in
// self.persistentDetailViewController is a view controller instantiated in
viewDidLoad.
- (void) addChildToDetailController {
[self.detailViewController
addChildViewController:self.persistentDetailViewController];
self.persistentDetailViewController.view.frame =
self.detailViewController.view.frame;
[self.detailViewController.view
addSubview:self.persistentDetailViewController.view];
[self.persistentDetailViewController
didMoveToParentViewController:self.detailViewController];
}
#pragma mark - Segues
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSDate *object = self.objects[indexPath.row];
self.detailViewController = (DetailViewController *)[[segue
destinationViewController] topViewController];
[self.detailViewController setDetailItem:object];
self.detailViewController.navigationItem.leftBarButtonItem =
self.splitViewController.displayModeButtonItem;
self.detailViewController.navigationItem.leftItemsSupplementBackButton =
YES;
[self addChildToDetailController];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden