• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reusable Detail View Controller for UISplitViewController?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Init String with bytes
  • Next by Date: Re: FSFileManager strange behaviour on OS X
  • Previous by thread: Re: Init String with bytes
  • Next by thread: Swift NSOutlineView "Illegal NSOutlineView data source"
  • Index(es):
    • Date
    • Thread