質問編集履歴
1
画面遷移部分(NextViewController)のコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,6 +26,148 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
+
###画面遷移部分のコード
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
class NextViewController: UIViewController{
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
@IBOutlet weak var timerLabel: UILabel!
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
@IBOutlet weak var timerFinishedLabel: UILabel!
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
var timer = Timer()
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
var count = Int()
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
override func viewDidLoad() {
|
58
|
+
|
59
|
+
super.viewDidLoad()
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
count = 0
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
@IBAction func start(_ sender: Any) {
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
startTimer()
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
@IBAction func stop(_ sender: Any) {
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
timer.invalidate()
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
@IBAction func back(_ sender: Any) {
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
dismiss(animated: true, completion: nil)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
// タイマーの機能
|
108
|
+
|
109
|
+
func startTimer(){
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timeUpdate), userInfo: nil, repeats: true)
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
// タイマーが押されたとき
|
122
|
+
|
123
|
+
@objc func timeUpdate(){
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
if count < 10 {
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
count += 1
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
timerLabel.text = String(count)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
if count >= 10 {
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
vibrate()
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
timerFinishedLabel.text = String("出来上がりました!!")
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
29
171
|
|
30
172
|
|
31
173
|
### 試したこと
|