現在教本にてクイズアプリを作成しています。
作成しているのは起動画面、問題画面、結果画面の3画面構成です。
問題画面の実装クラスにて以下のコードがあります。
//ViewControllerを作成する
箇所なのですが、StoryboardでresultViewControllerは作成しているのに
新たにVCを作るとはどういうことなのでしょうか?
またこの文法はなんと調べればででくるでしょうか?
//次の問題へ遷移する func goNextQuestion() { //問題文の取り出し guard let nextQuestion = QuestionDataManager.sharedInstance.nextQuestion() else { //問題文がなければ結果画面へ遷移する //StoryboardのIdentifierに設定した値(result)を指定して //ViewControllerを生成する if let resultViewController = storyboard?.instantiateViewController(withIdentifier: "result") as? ResultViewController { //StoryboardのSegueを利用しない明示的な画面遷移処理 present(resultViewController, animated: true, completion: nil) } return } //問題文がある場合は次の問題へ遷移する //StroyBoardのIdentiferに設定した値(question)を設定して //ViewControllerを生成する if let nextQuestionViewController = storyboard?.instantiateViewController(withIdentifier: "question") as? QuestionViewController { nextQuestionViewController.questionData = nextQuestion //StoryBoardのSegueをを利用しない明示的な画面遷移 present(nextQuestionViewController, animated: true, completion: nil) } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/17 03:29