It is possible to use an existing ViewController with PerformSegueWithIdentifier?

后端 未结 7 1362
一整个雨季
一整个雨季 2020-12-31 05:32

I use the method performSegueWithIdentifier:sender: to open a new ViewController from a storyboard-file programmatically. This works like a charm.<

7条回答
  •  隐瞒了意图╮
    2020-12-31 05:40

    To reuse an existing UIViewController instance with a segue create the segue from scratch and provide your own (existing) destination (UIViewController). Do not forget to call prepareForSegue: if needed.

    For example:

    UIStoryboardSegue* aSegue = [[UIStoryboardSegue alloc] initWithIdentifier:@"yourSegueIdentifier" source:self destination:self.existingViewController]
    [self prepareForSegue:aSegue sender:self];
    [aSegue perform];
    

提交回复
热议问题