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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to