Among the three types of StoryBoard connections, one type is Custom. Developers can use custom Segue. Custom Segue classes need to inherit the class UIStoryBoardSegue and override the perform method. :
- (void)perform{ NSLog(@"使用自定义连接"); [self.sourceViewController presentViewController:self.destinationViewController animated:YES completion:nil];}
The operation effect is the same as using Modal type connection directly:
Of course, you can also customize Push type connections
If you want the content between pages to be related, you need to implement inter-page transfer Value. In StoryBoard, the page value is passed through the prepareForSegue:sender: method. First set the connection Identifier to 2vc2 (you can name it according to your own needs, just keep it consistent with the string in the code)
Drag and drop a UITextView instance to page 2 , and associate the output port recTextView
Add the following code in ViewController.m:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([[segue identifier] isEqualToString:@"2vc2"]) { ViewController2 *vc2 = (ViewController2 *)[segue destinationViewController]; vc2.passText = @"使用prepareForSegue:sender进行页面传值"; }}
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _recTextView.text = _passText;}