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

回答編集履歴

2

コメントのもれ

2019/12/19 06:29

投稿

vanderlvov
vanderlvov

スコア687

answer CHANGED
@@ -1,3 +1,5 @@
1
+ `didSelectRow`を追加する必要があります。
2
+
1
3
  ```swift
2
4
  func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
3
5
  {

1

追加

2019/12/19 06:29

投稿

vanderlvov
vanderlvov

スコア687

answer CHANGED
@@ -1,10 +1,11 @@
1
1
  ```swift
2
- func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent component: Int)
2
+ func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
3
- {
3
+ {
4
+ if component == 0 {
4
- println("(courseCatalog[row])")
5
+ timeCountLabel.text = String(format: "%.1f", list1[row])
5
- yourlabelname.text=courseCatalog[row]
6
+ interval = list1[row]
6
-
7
- }
7
+ }
8
+ }
8
9
  ```
9
10
 
10
11
  全てのコードはこうなります;
@@ -17,7 +18,7 @@
17
18
  @IBOutlet weak var PickerView: UIPickerView!
18
19
 
19
20
  var timer: Timer?
20
-
21
+ var interval = 0.0
21
22
  var count: Int = 0
22
23
 
23
24
  //カウントアップの間隔
@@ -44,6 +45,7 @@
44
45
  print(component)
45
46
  if component == 0 {
46
47
  timeCountLabel.text = String(format: "%.1f", list1[row])
48
+ interval = list1[row]
47
49
  }
48
50
  }
49
51
 
@@ -82,8 +84,9 @@
82
84
  // 起動中のタイマーを無効化
83
85
  timer?.invalidate()
84
86
 
85
- timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { (timer) in
87
+ timer = Timer.scheduledTimer(withTimeInterval: self.interval, repeats: true) { (timer) in
86
88
 
89
+ print("counter")
87
90
  self.count = self.count + 1
88
91
 
89
92
  DispatchQueue.main.async {