Creating a segue programmatically

前端 未结 13 1110
名媛妹妹
名媛妹妹 2020-11-22 12:41

I have a common UIViewController that all my UIViewsControllers extend to reuse some common operations.

I want to set up a segue on this \"

13条回答
  •  爱一瞬间的悲伤
    2020-11-22 13:05

    You have to link your code to the UIStoryboard that you're using. Make sure you go into YourViewController in your UIStoryboard, click on the border around it, and then set its identifier field to a NSString that you call in your code.

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" 
                                                         bundle:nil];
    YourViewController *yourViewController = 
     (YourViewController *)
      [storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerID"];
    [self.navigationController pushViewController:yourViewController animated:YES];
    

提交回复
热议问题