回答編集履歴
2
修正および追記
test
CHANGED
@@ -4,25 +4,55 @@
|
|
4
4
|
|
5
5
|
```swift
|
6
6
|
|
7
|
-
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
|
7
|
+
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
|
8
8
|
|
9
|
+
|
10
|
+
|
11
|
+
switch pickerView {
|
12
|
+
|
9
|
-
|
13
|
+
case agepicker:
|
10
14
|
|
11
15
|
return agedataList.count
|
12
16
|
|
13
|
-
|
17
|
+
case seibetupicker:
|
14
18
|
|
15
19
|
return seibetudataList.count
|
16
20
|
|
17
|
-
|
21
|
+
case seasonpicker:
|
18
22
|
|
19
23
|
return seasonList.count
|
20
24
|
|
21
|
-
|
25
|
+
case Prefecturespicker:
|
22
26
|
|
23
|
-
|
27
|
+
return PrefecturesList.count
|
28
|
+
|
29
|
+
default:
|
30
|
+
|
31
|
+
fatalError()
|
24
32
|
|
25
33
|
}
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
// if pickerView == agepicker {
|
38
|
+
|
39
|
+
// return agedataList.count
|
40
|
+
|
41
|
+
// } else if pickerView == seibetupicker {
|
42
|
+
|
43
|
+
// return seibetudataList.count
|
44
|
+
|
45
|
+
// } else if pickerView == seasonpicker {
|
46
|
+
|
47
|
+
// return seasonList.count
|
48
|
+
|
49
|
+
// } else {
|
50
|
+
|
51
|
+
// return PrefecturesList.count
|
52
|
+
|
53
|
+
// }
|
54
|
+
|
55
|
+
|
26
56
|
|
27
57
|
}
|
28
58
|
|
@@ -60,8 +90,8 @@
|
|
60
90
|
|
61
91
|
|
62
92
|
|
63
|
-
としてしまえば動き
|
93
|
+
としてしまえば動きます(動作確認済み)。
|
64
94
|
|
65
95
|
|
66
96
|
|
67
|
-
|
97
|
+
プラスαとしてswitch文も書いてみました。```pickerView(_:titleForRow:forComponent:)```の方もswitch文で書いてみれば練習になるでしょう。
|
1
追記
test
CHANGED
@@ -61,3 +61,7 @@
|
|
61
61
|
|
62
62
|
|
63
63
|
としてしまえば動きそうな気がします(動作は未確認です)。
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
ちなみに4つも条件分岐あるならswitch文を書くのもアリです。
|