Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Sorry, but I cannot post my source code as it contains sensitive information. When I have more time available I will create a separate project and upload the code somewhere. </p> <p>Here are extracts of how I have done it so far (I welcome any feedback).</p> <p>The RootViewController - Note I have 4 sections in my root table.</p> <pre><code>#pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; // Detail view logic NSUInteger section = indexPath.section; UIViewController &lt;SubstitutableDetailViewController&gt; *detailViewController = nil; if (section == 2) { ProductSearchDetailView *viewController = [[ProductSearchDetailView alloc] initWithNibName:@"ProductSearchDetailView" bundle:nil]; detailViewController = viewController; //[viewController release]; } else { DetailViewController *defaultDetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil]; detailViewController = defaultDetailViewController; //[defaultDetailViewController release]; } // Navigation logic switch (section) { case 0: { break; } case 1: { break; } case 2: { // new Navigation view ProductSearchViewController *viewController = [[ProductSearchViewController alloc] initWithNibName:@"ProductSearchViewController" bundle:nil]; viewController.navigationItem.backBarButtonItem.title = @"Back"; [self.navigationController pushViewController:viewController animated:YES]; [viewController release]; break; } case 3: { StoreLocatorNavController *viewController = [[StoreLocatorNavController alloc] initWithNibName:@"StoreLocatorNavController" bundle:nil]; viewController.navigationItem.backBarButtonItem.title = @"Back"; [self.navigationController pushViewController:viewController animated:YES]; [viewController release]; break; } } // Update the split view controller's view controllers array. NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil]; splitViewController.viewControllers = viewControllers; [viewControllers release]; // Dismiss the popover if it's present. if (popoverController != nil) { [popoverController dismissPopoverAnimated:YES]; } // Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created). if (rootPopoverButtonItem != nil) { [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem]; } [detailViewController release]; } </code></pre> <p><em><strong>NSNotificationCenter part</em></strong> </p> <p>Add this to ProductSearchViewController:</p> <pre><code>#pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *itemAtIndex = (NSDictionary *)[self.productResults objectAtIndex:indexPath.row]; [[NSNotificationCenter defaultCenter] postNotificationName:@"updateProduct" object:itemAtIndex]; } </code></pre> <p>And finally, add this to ProductSearchDetailViewController:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTheProductDetails:) name:@"updateProduct" object:nil]; } - (void)updateTheProductDetails:(NSNotification *)notification { NSDictionary *productDictionary = [NSDictionary dictionaryWithDictionary:[notification object]]; // product name _productName.text = [productDictionary objectForKey:@"ProductDescription"]; } </code></pre> <p>Hope it helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload