It is possible to use an existing ViewController with PerformSegueWithIdentifier?

后端 未结 7 1364
一整个雨季
一整个雨季 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:55

    Create a property for the controller.

    @property (nonatomic, weak) MyController controller;
    

    And use some kind of lazy initialization in performSegueWithIdentifier:sender

    if (self.controller == nil)
    {
    self.controller = [MyController alloc] init]
    ...
    }
    

    In this case, if controller was already created, it will be reused.

    0 讨论(0)
提交回复
热议问题