问题描述
class MoviesViewController5: UIViewController {
static let sharedInstance: MoviesViewController5 = MoviesViewController5()
func fillPage2(menuId menuId:String) {
// ...
}
}
当我尝试像这样访问fillPage2时:
class TabsBarController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tab4ViewController = UIStoryboard(name: "Main",bundle: Bundle.main).instantiateViewController(identifier: "MoviesViewController5") as! MoviesViewController5
// Add each ViewController to your viewControllers array
// This throws an error
tab4ViewController.sharedInstance.fillPage2(menuId: "2")
// Static member 'sharedInstance' cannot be used on instance of type 'MoviesViewController5'
}
}
这是错误:
静态成员'sharedInstance'不能用于类型的实例 'MoviesViewController5'
tab4ViewController实际上将代表视图。因此,我需要在其上调用fillPage2
方法。
知道我在做什么错吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)