teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

質問画面でyesを押した時のメソッドの追加

2020/07/01 01:12

投稿

987654321
987654321

スコア28

title CHANGED
File without changes
body CHANGED
@@ -12,6 +12,23 @@
12
12
  }
13
13
  goNextQuestion()
14
14
  }
15
+
16
+
17
+ func goNextQuestion() {
18
+      // 次の質問がない場合は結果画面に行く
19
+ guard let nextQuestion = QuestionDataMannager.shareInstance.nextQuestion() else {
20
+ if let resultViewController = storyboard?.instantiateViewController(identifier: "result") as? ResultViewController {
21
+ present(resultViewController, animated: true, completion: nil)
22
+ }
23
+ return
24
+ }
25
+
26
+ // 次の質問へ行く
27
+ if let nextQuestionViewController = storyboard?.instantiateViewController(withIdentifier: "question") as? QuestionViewController {
28
+ nextQuestionViewController.questionData = nextQuestion
29
+ present(nextQuestionViewController, animated: true, completion: nil)
30
+ }
31
+ }
15
32
  ```
16
33
 
17
34
  結果画面のコントローラー