我有一个称为UIViewController
的基本BaseController
,它是通过我的segue
中的storyboard
调用的。现在,我有此baseController的两个子类-Subclass1
和Subclass2
。我想在触发SubBaseController1
时根据目标调用SubBaseController2
或segue
。当调用SubBaseController1
时,如何实例化target1
中的SubBaseController2
或target
2中的segue
?
您可以通过两种方式进行:
performSegue(withIdentifier: "segue1", sender: nil)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let viewController1 = storyboard.instantiateViewController(identifier: "viewController1")
present(viewController1, animated: true)
我将推荐第二种方法,因为它可以让您更好地控制显示过程。