回答編集履歴
1
追記
answer
CHANGED
@@ -12,4 +12,38 @@
|
|
12
12
|
}
|
13
13
|
```
|
14
14
|
|
15
|
-
ここで使っているSegueの張り間違いのどちらかでしょうか。
|
15
|
+
ここで使っているSegueの張り間違いのどちらかでしょうか。
|
16
|
+
|
17
|
+
---
|
18
|
+
条件分岐の例(`switch-case` でもいいですし、それ以外のやり方もあると思います)
|
19
|
+
```Swift
|
20
|
+
import UIKit
|
21
|
+
|
22
|
+
class ViewController: UIViewController {
|
23
|
+
override func viewDidLoad() {
|
24
|
+
super.viewDidLoad()
|
25
|
+
// Do any additional setup after loading the view.
|
26
|
+
}
|
27
|
+
|
28
|
+
@IBAction func toFirstButton(_ sender: Any) {
|
29
|
+
performSegue(withIdentifier: "toFirst", sender: nil)
|
30
|
+
}
|
31
|
+
|
32
|
+
@IBAction func toSecondButton(_ sender: Any) {
|
33
|
+
performSegue(withIdentifier: "toSecond", sender: nil)
|
34
|
+
}
|
35
|
+
|
36
|
+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
37
|
+
if segue.identifier == "toFirst" {
|
38
|
+
print("toFirst Segue")
|
39
|
+
// 処理
|
40
|
+
|
41
|
+
} else if segue.identifier == "toSecond" {
|
42
|
+
print("toSecond Segue")
|
43
|
+
// 処理
|
44
|
+
} else {
|
45
|
+
// 必要だったら想定外の処理
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
```
|