【Sample Code】Configuring the Destination Controller When a Segue is Triggered

来源:互联网 发布:液流电池 知乎 编辑:程序博客网 时间:2024/06/04 16:29

iOS performs the following tasks when a segue is triggered: 

  1. It instantiates the destination view controller.

  2. It instantiates a new segue object that holds all the information for the segue being triggered.

    Note: Apopoverseguealsoprovidesapropertythatidentifiesthepopovercontrollerusedtocontrol the destination view controller.

  3. It calls the source view controller’sprepareForSegue:sender:method, passing in the new segue objectand the object that triggered the segue.

  4. It calls the segue’s performmethod to bring the destination controller onto the screen. The actual behaviordepends on the kind of segue being performed. For example, a modal segue tells the source view controllerto present the destination view controller.

  5. It releases the segue object and the segue is complete. 


Configuring the destination controller in a segue 

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender  {      if ([[segue identifier] isEqualToString:@"ShowSightingsDetails"])      {          DetailViewController *detailViewController = [segue  destinationViewController];          detailViewController.sighting = [self.dataController  objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];}      if ([[segue identifier] isEqualToString:@"ShowAddSightingView"])      {          AddSightingViewController *addSightingViewController = [[[segue  destinationViewController] viewControllers] objectAtIndex:0];          addSightingViewController.delegate = self;} }


0 0
原创粉丝点击