是否可以在ViewModel对象或类中推送ViewController

时间:2017-11-02 15:25:34

标签: ios model-view-controller mvvm uiviewcontroller swift4

是否可以从ViewModel Object推送UIViewController。当我试图推送时,语句正在执行,但UI没有任何变化。这是我的代码,

@objc func attemptQuiz(sender: UIButton){
    UserDefaults.standard.setValue(sender.tag, forKey: "Quiz_ID")
    let quizListVC = QuizList_ViewController(nibName: "QuizList_ViewController", bundle: nil)
    let attemptVC = AttemptQuiz_ViewController(nibName: "AttemptQuiz_ViewController", bundle: nil)
    quizListVC.navigationController?.pushViewController(attemptVC, animated: true)
}

这里,func attemptQuiz和它的调用是在ViewModel对象/类中    QuizList_ViewController不在UIViewController类

0 个答案:

没有答案