質問編集履歴
2
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -211,3 +211,121 @@
|
|
211
211
|
|
212
212
|
|
213
213
|
![イメージ説明](e9a428bd76208c44e0de0d54591b06f3.png)
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
|
220
|
+
|
221
|
+
// 選択時の処理
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
let minute = dataList[pickerView.selectedRow(inComponent: 0)]
|
226
|
+
|
227
|
+
let second = dataList2[pickerView.selectedRow(inComponent: 1)]
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
//print("\(minute):\(second)")
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
**修正箇所**
|
236
|
+
|
237
|
+
label.text = "\(minute):\(second)"
|
238
|
+
|
239
|
+
print(String(format: "%02d:%02d", minute, second))
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
@IBAction func startbutton(_ sender: Any) {
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
let minutes = dataList[pickerView.selectedRow(inComponent: 0)]
|
248
|
+
|
249
|
+
let seconds = dataList2[pickerView.selectedRow(inComponent: 1)]
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
**修正箇所**
|
254
|
+
|
255
|
+
time = Int(minutes)! * 60 + Int(seconds)!
|
256
|
+
|
257
|
+
print(String(format: "%02d:%02d", minutes, seconds))
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.letGo),userInfo: nil, repeats: true)
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
//タイマーから呼び出されるメソッド
|
268
|
+
|
269
|
+
func letGo(){
|
270
|
+
|
271
|
+
time -= 1
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
**修正箇所**
|
276
|
+
|
277
|
+
label.text = "\(time / 60):\(time % 60)"
|
278
|
+
|
279
|
+
print(String(format: "%02d:%02d", time, time))
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
if time <= 0 {
|
284
|
+
|
285
|
+
timer.invalidate()
|
286
|
+
|
287
|
+
label.text = "Finish"
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
@IBAction func finishbutton(_ sender: Any) {
|
296
|
+
|
297
|
+
timer.invalidate()
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
let minutes = dataList[pickerView.selectedRow(inComponent: 0)]
|
302
|
+
|
303
|
+
let seconds = dataList2[pickerView.selectedRow(inComponent: 1)]
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
time = Int(minutes)! * 60 + Int(seconds)!
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
**修正箇所**
|
312
|
+
|
313
|
+
label.text = "\(minutes):\(seconds)"
|
314
|
+
|
315
|
+
print(String(format: "%02d:%02d", minutes, seconds))
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
override func didReceiveMemoryWarning() {
|
322
|
+
|
323
|
+
super.didReceiveMemoryWarning()
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
```
|
1
写真の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -207,3 +207,7 @@
|
|
207
207
|
```
|
208
208
|
|
209
209
|
の代入させ方が分からなくて困っています。
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
![イメージ説明](e9a428bd76208c44e0de0d54591b06f3.png)
|