不能从myCoustomClass中获取

时间:2017-06-10 11:58:06

标签: swift downcast

class MyCViewContollerClass:UIViewController{

    var button = UIButton()
}

let storyBoard = UIStoryboard()
let viewController = storyBoard.instantiateViewController(withIdentifier: "vc") as! MyCViewContollerClass

1 个答案:

答案 0 :(得分:1)

您需要从文件中加载故事板:

let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)

或者,如果您没有故事板,则可以通过编程方式创建视图控制器:

let viewController = MyCViewControllerClass()