Swift: prepareForSegue with two different segues

后端 未结 5 912
旧时难觅i
旧时难觅i 2021-01-04 19:29

I have 2 UIButtons on a view. Each of them are linked to 2 different views. They have to pass different data depending which button you just tapped.

I k

5条回答
  •  鱼传尺愫
    2021-01-04 19:40

    In order to navigate different segues in objective C you need to follow these actions.

    1. Click on the actual segue on storyboard
    2. Go to attribute inspector and rename the identifier of the segue
    3. customize the code as following, here's an example:

      -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
      if([segue.identifier isEqualToString:@"segueNumberOne"]){
          YourViewController *functionalityViewController = [segue destinationViewController];
          functionalityViewController.someProperty = someValue;
          NSLog(@"move to segue number 1");
      }else if ([segue.identifier isEqualToString:@"segueNumberTwo"]){
          NSLog(@"move to segue number 2");
      }
      

提交回复
热议问题