質問編集履歴

2

タイトル変更

2018/12/06 06:49

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 遅延をおいて次の画面に遷移するようにしたいです
1
+ Timerによる一定時間後に次の画面に遷移するようにしたいです
test CHANGED
@@ -10,274 +10,260 @@
10
10
 
11
11
 
12
12
 
13
+ どこにどのように入れれば良いのか教えていただけないでしょうか。
14
+
15
+ 同じようにTiemrを使って行えば良いのでしょうか。
16
+
17
+
18
+
19
+
20
+
21
+ ###対象ソースコード
22
+
23
+
24
+
13
- ```swift
25
+ ```swift
26
+
27
+
28
+
14
-
29
+ var timer:Timer!
30
+
31
+
32
+
33
+ var count:Int = 0
34
+
35
+
36
+
37
+ var dispImageNo = 0
38
+
39
+
40
+
41
+ var imageView = UIImageView()
42
+
43
+
44
+
45
+
46
+
47
+ override func loadView() {
48
+
49
+ let view07A = UIView()
50
+
51
+ view07A.frame = CGRect(x:0, y:0, width:375, height:669)
52
+
53
+ view07A.backgroundColor = .white
54
+
55
+ self.view = view07A
56
+
57
+
58
+
59
+
60
+
61
+ }
62
+
63
+
64
+
65
+ @objc func timerAction(sender:Timer){
66
+
67
+
68
+
69
+ count = count + 1
70
+
71
+
72
+
73
+ dispImageNo = count % 7
74
+
75
+
76
+
77
+ print("カウントダウン")
78
+
79
+
80
+
81
+ pictureView()
82
+
83
+
84
+
85
+
86
+
87
+ }
88
+
89
+ override func viewDidLoad() {
90
+
91
+ super.viewDidLoad()
92
+
93
+
94
+
95
+ createTimer()
96
+
97
+
98
+
99
+ }
100
+
101
+
102
+
103
+ func createTimer () {
104
+
105
+
106
+
107
+ timer = Timer.scheduledTimer(timeInterval:5.0,
108
+
109
+ target:self,
110
+
111
+ selector: #selector(ViewController_7A.timerAction(sender:)),
112
+
113
+ userInfo:nil,
114
+
115
+ repeats:true)
116
+
117
+
118
+
119
+
120
+
15
- DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
121
+ DispatchQueue.main.asyncAfter(deadline: .now() + 40.0) {
122
+
16
-
123
+ print("終わり")
17
-
124
+
125
+
18
126
 
19
127
  }
20
128
 
129
+
130
+
131
+ }
132
+
133
+ func pictureView() {
134
+
135
+
136
+
137
+ let pictureArray = [
138
+
139
+ //画像
140
+
141
+ ]
142
+
143
+
144
+
145
+
146
+
147
+ let name = pictureArray[dispImageNo]
148
+
149
+
150
+
151
+ let image = UIImage(named:name)
152
+
153
+
154
+
155
+ self.imageView.image = image
156
+
157
+
158
+
159
+
160
+
161
+ imageView.frame = CGRect(x:0, y:0, width:200, height:300)
162
+
163
+
164
+
165
+ let screenWidth:CGFloat = view.frame.size.width
166
+
167
+ let screenHeight:CGFloat = view.frame.size.height
168
+
169
+
170
+
171
+
172
+
173
+ self.imageView.center = CGPoint(x:screenWidth/2, y:screenHeight/2)
174
+
175
+
176
+
177
+ view.addSubview(self.imageView)
178
+
179
+
180
+
181
+ }
182
+
183
+
184
+
185
+ @objc func tapp(_ sender:UIButton) {
186
+
187
+
188
+
189
+ let nextvc = ViewController_7A()
190
+
191
+
192
+
193
+ self.present(nextvc, animated: true, completion: nil)
194
+
195
+ }
196
+
197
+
198
+
199
+
200
+
201
+ }
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+ class ViewController_8:UIViewController {
216
+
217
+
218
+
219
+ override func loadView() {
220
+
221
+ let view = UIView()
222
+
223
+ view.frame = CGRect(x:0, y:0, width:375, height:669)
224
+
225
+ view.backgroundColor = .white
226
+
227
+ self.view = view
228
+
229
+
230
+
231
+ let lbl1 = UILabel()
232
+
233
+ lbl1.frame = CGRect(x:40, y:100, width:130, height:50)
234
+
235
+ lbl1.text = "言葉"
236
+
237
+ lbl1.textColor = .black
238
+
239
+ view.addSubview(lbl1)
240
+
241
+
242
+
243
+ let tt_answer = UITextView()
244
+
245
+ tt_answer.frame = CGRect(x:40, y:150, width:180, height:100)
246
+
247
+ tt_answer.textColor = .black
248
+
249
+ tt_answer.text = "言葉"
250
+
251
+ view.addSubview(tt_answer)
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ }
262
+
263
+
264
+
265
+ }
266
+
267
+
268
+
21
269
  ```
22
-
23
-
24
-
25
- 上記のコード入れるまでしか分からずにいます。
26
-
27
- どこにどのように入れれば良いのか教えていただけないでしょうか。
28
-
29
- 同じようにTiemrを使って行えば良いのでしょうか。
30
-
31
-
32
-
33
-
34
-
35
- ###対象ソースコード
36
-
37
-
38
-
39
- ```swift
40
-
41
-
42
-
43
- var timer:Timer!
44
-
45
-
46
-
47
- var count:Int = 0
48
-
49
-
50
-
51
- var dispImageNo = 0
52
-
53
-
54
-
55
- var imageView = UIImageView()
56
-
57
-
58
-
59
-
60
-
61
- override func loadView() {
62
-
63
- let view07A = UIView()
64
-
65
- view07A.frame = CGRect(x:0, y:0, width:375, height:669)
66
-
67
- view07A.backgroundColor = .white
68
-
69
- self.view = view07A
70
-
71
-
72
-
73
-
74
-
75
- }
76
-
77
-
78
-
79
- @objc func timerAction(sender:Timer){
80
-
81
-
82
-
83
- count = count + 1
84
-
85
-
86
-
87
- dispImageNo = count % 7
88
-
89
-
90
-
91
- print("カウントダウン")
92
-
93
-
94
-
95
- pictureView()
96
-
97
-
98
-
99
-
100
-
101
- }
102
-
103
- override func viewDidLoad() {
104
-
105
- super.viewDidLoad()
106
-
107
-
108
-
109
- createTimer()
110
-
111
-
112
-
113
- }
114
-
115
-
116
-
117
- func createTimer () {
118
-
119
-
120
-
121
- timer = Timer.scheduledTimer(timeInterval:5.0,
122
-
123
- target:self,
124
-
125
- selector: #selector(ViewController_7A.timerAction(sender:)),
126
-
127
- userInfo:nil,
128
-
129
- repeats:true)
130
-
131
-
132
-
133
-
134
-
135
- DispatchQueue.main.asyncAfter(deadline: .now() + 40.0) {
136
-
137
- print("終わり")
138
-
139
-
140
-
141
- }
142
-
143
-
144
-
145
- }
146
-
147
- func pictureView() {
148
-
149
-
150
-
151
- let pictureArray = [
152
-
153
- //画像
154
-
155
- ]
156
-
157
-
158
-
159
-
160
-
161
- let name = pictureArray[dispImageNo]
162
-
163
-
164
-
165
- let image = UIImage(named:name)
166
-
167
-
168
-
169
- self.imageView.image = image
170
-
171
-
172
-
173
-
174
-
175
- imageView.frame = CGRect(x:0, y:0, width:200, height:300)
176
-
177
-
178
-
179
- let screenWidth:CGFloat = view.frame.size.width
180
-
181
- let screenHeight:CGFloat = view.frame.size.height
182
-
183
-
184
-
185
-
186
-
187
- self.imageView.center = CGPoint(x:screenWidth/2, y:screenHeight/2)
188
-
189
-
190
-
191
- view.addSubview(self.imageView)
192
-
193
-
194
-
195
- }
196
-
197
-
198
-
199
- @objc func tapp(_ sender:UIButton) {
200
-
201
-
202
-
203
- let nextvc = ViewController_7A()
204
-
205
-
206
-
207
- self.present(nextvc, animated: true, completion: nil)
208
-
209
- }
210
-
211
-
212
-
213
-
214
-
215
- }
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
- class ViewController_8:UIViewController {
230
-
231
-
232
-
233
- override func loadView() {
234
-
235
- let view = UIView()
236
-
237
- view.frame = CGRect(x:0, y:0, width:375, height:669)
238
-
239
- view.backgroundColor = .white
240
-
241
- self.view = view
242
-
243
-
244
-
245
- let lbl1 = UILabel()
246
-
247
- lbl1.frame = CGRect(x:40, y:100, width:130, height:50)
248
-
249
- lbl1.text = "言葉"
250
-
251
- lbl1.textColor = .black
252
-
253
- view.addSubview(lbl1)
254
-
255
-
256
-
257
- let tt_answer = UITextView()
258
-
259
- tt_answer.frame = CGRect(x:40, y:150, width:180, height:100)
260
-
261
- tt_answer.textColor = .black
262
-
263
- tt_answer.text = "言葉"
264
-
265
- view.addSubview(tt_answer)
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
- }
276
-
277
-
278
-
279
- }
280
-
281
-
282
-
283
- ```

1

タイトル変更

2018/12/06 06:49

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 自動画面遷移の方法がわからないです
1
+ 遅延をおいて次の画面遷移するようにしたいです
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Timerを使って画像を一定時間ごとに表示して行った後、
8
8
 
9
- 次のViewControllerに自動的に遷移をしたいのですが、
9
+ 次のViewControllerに遷移をしたいのですが、
10
10
 
11
11
 
12
12
 
@@ -26,6 +26,8 @@
26
26
 
27
27
  どこにどのように入れれば良いのか教えていただけないでしょうか。
28
28
 
29
+ 同じようにTiemrを使って行えば良いのでしょうか。
30
+
29
31
 
30
32
 
31
33