我在Storyboard中创建了ViewController,我正在使用它
instantiateViewControllerWithIdentifier:
加载它.但我需要将此VC作为基类,并使用3-4个子类来更改其属性.
如何使用instantiateViewControllerWithIdentifier获取我的子类的实例?
解决方法
Swift 3中的@Bhagyesh版本:
class func instantiateFromSuperclassStoryboard() -> SubclassViewController { let stroryboard = UIStoryboard(name: "Main",bundle: nil) let controller = stroryboard.instantiateViewController(withIdentifier: "BaseViewController") object_setClass(controller,SubclassViewController.self) return controller as! SubclassViewController }