Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For demo purpose, I will assume we have two view controllers <code>ListViewController</code> and <code>DetailViewController</code>. ListViewController has tableview and you have created a <code>segue between your tableview cell and details view controller</code>.</p> <p>I'm assuming you are naming it as 'DetailSegue'. Your storyboard should look similar to the below image.</p> <p><img src="https://i.stack.imgur.com/uAYxW.png" alt="enter image description here"></p> <p>Select the segue between tableViewCell and DetailViewController, open the attributes inspector and specify the identifier as 'DetailSegue'. See the image below,</p> <p><img src="https://i.stack.imgur.com/v1sCi.png" alt="enter image description here"></p> <p>Run the application now, you should see a smooth navigation from ListViewController to DetailViewController. </p> <p><code>Assuming you datasource is an array of stings and you have your datasource and delegate setup already properly for your list tableView</code>.</p> <p>Add a method prepareForSegue:sender in your List view controller, this method will get called whenever segue is about to execute.This method will be automatically invoked.</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"DetailSegue"]) { DetailViewController *detailVC = (DetailViewController*)segue.destinationViewController; NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)sender]; detailVC.title = [self.source objectAtIndex:indexPath.row]; } } </code></pre> <p>Add a property called <code>title</code> in DetailViewController to store the selected title and add another outlet for UILabel to display the title in the view.</p> <p>DetailViewController.h</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface RecipeListViewController : NSObject @property (weak, nonatomic) NSString *title; @property (weak, nonatomic) IBOutlet UILabel *titleLabel; @end </code></pre> <hr> <p>DetailViewController.m</p> <pre><code>@implementation RecipeListViewController - (void)viewDidLoad { [super viewDidLoad]; self.titleLabel.text = self.title; } @end </code></pre> <p>Don't forget to connect the outlet. I hope this gives you an rough idea of how we can pass data between view controllers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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