我有一个班级LeftViewController
:
protocol LeftMenuProtocol: class {
func actionOpenHome()
func actionOpenTakeSnap()
func actionOpenGallery()
func actionOpenProfiles()
func actionOpenSettings()
func actionOpenHelp()
func actionOpenContactUs()
func actionOpenBarCode()
func actionOpenAbout()
func actionCloseSideVC()
}
class LeftViewController : UIViewController {
@IBOutlet weak var tableView: UITableView!
var leftMenuDelegate : LeftMenuProtocol?
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.view.layoutIfNeeded()
}
}
我正在尝试将其添加到另一个类
中var leftViewController: LeftViewController!
leftViewController = self.storyboard!.instantiateViewControllerWithIdentifier("LeftViewController")
self.addChildViewController(leftViewController)
self.view!.addSubview(leftViewController.view!)
leftViewController.didMoveToParentViewController(self)`
但是得到了这个错误。有人知道出了什么问题吗?
答案 0 :(得分:4)
将变量声明更改为
leftViewController = self.storyboard!.instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController
你需要明确地施展它。