Subclass ViewController from Storyboard

后端 未结 3 940
野趣味
野趣味 2020-12-17 16:11

I created ViewController in Storyboard and I am using

instantiateViewControllerWithIdentifier:

to load it. But I need to have this VC as b

3条回答
  •  执念已碎
    2020-12-17 16:40

    Just cast it.

    MyController *controller = (MyController *)[self.storyboard instantiateViewControllerWithIdentifier:@"myController"];
    

    or Swift:

    let controller = storyboard?.instantiateViewControllerWithIdentifier("myController") as! MyController
    

提交回复
热议问题