質問編集履歴
6
内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -280,6 +280,8 @@
|
|
280
280
|
|
281
281
|
})
|
282
282
|
|
283
|
+
task.resume()
|
284
|
+
|
283
285
|
}
|
284
286
|
|
285
287
|
|
5
present(alert,....)の中身を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -220,7 +220,7 @@
|
|
220
220
|
|
221
221
|
alert.addAction(cancel)
|
222
222
|
|
223
|
-
present(alert: true, completion: nil)
|
223
|
+
present(alert:, animated: true, completion: nil)
|
224
224
|
|
225
225
|
}
|
226
226
|
|
@@ -258,7 +258,7 @@
|
|
258
258
|
|
259
259
|
alert.addAction(next)
|
260
260
|
|
261
|
-
present(alert: true, completion: nil)
|
261
|
+
present(alert, animated: true, completion: nil)
|
262
262
|
|
263
263
|
}
|
264
264
|
|
@@ -292,10 +292,10 @@
|
|
292
292
|
|
293
293
|
alert.addAction(cancel)
|
294
294
|
|
295
|
-
present(alert: true, completion: nil)
|
295
|
+
present(alert, animated: true, completion: nil)
|
296
|
-
|
296
|
+
|
297
|
-
}
|
297
|
+
}
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
-
```
|
301
|
+
```
|
4
内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -256,6 +256,8 @@
|
|
256
256
|
|
257
257
|
alert.addAction(cancel)
|
258
258
|
|
259
|
+
alert.addAction(next)
|
260
|
+
|
259
261
|
present(alert: true, completion: nil)
|
260
262
|
|
261
263
|
}
|
3
内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -248,23 +248,7 @@
|
|
248
248
|
|
249
249
|
let next: UIAlertAction = UIAlertAction(title: "次へ", style: .default, handler: {(action: UIAlertAction) -> Void in
|
250
250
|
|
251
|
-
func httpRequest(urlst: String) {
|
252
|
-
|
253
|
-
var req = URLRequest(url: URL(string: urlst)!)
|
254
|
-
|
255
|
-
req.httpMethod = "GET"
|
256
|
-
|
257
|
-
|
251
|
+
httpRequest(urlst: "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
258
|
-
|
259
|
-
DispathQueue.main.async {
|
260
|
-
|
261
|
-
self.alert(msg: "接続失敗")
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
})
|
266
|
-
|
267
|
-
}
|
268
252
|
|
269
253
|
})
|
270
254
|
|
@@ -278,6 +262,26 @@
|
|
278
262
|
|
279
263
|
|
280
264
|
|
265
|
+
func httpRequest(urlst: String) {
|
266
|
+
|
267
|
+
var req = URLRequest(url: URL(string: urlst)!)
|
268
|
+
|
269
|
+
req.httpMethod = "GET"
|
270
|
+
|
271
|
+
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
|
272
|
+
|
273
|
+
DispathQueue.main.async {
|
274
|
+
|
275
|
+
self.alert(msg: "接続失敗")
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
})
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
|
281
285
|
func alert(msg: String) {
|
282
286
|
|
283
287
|
let alert = UIAlertController(title: nil, message: msg, preferredStyle: .alert)
|
2
問題のコードの内容を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -227,3 +227,69 @@
|
|
227
227
|
|
228
228
|
|
229
229
|
```
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
### さらに追記
|
234
|
+
|
235
|
+
調べたところ、どうやらアラートを呼び出している最中にアラートを呼び出しているのが問題のようでした。
|
236
|
+
|
237
|
+
関係ないだろうと質問を省いていました、申し訳ございません。
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```swift
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
@IBAction func Button(_ sender: Any) {
|
246
|
+
|
247
|
+
let alert = UIAlertController(title: nil, message: msg, preferredStyle: .alert)
|
248
|
+
|
249
|
+
let next: UIAlertAction = UIAlertAction(title: "次へ", style: .default, handler: {(action: UIAlertAction) -> Void in
|
250
|
+
|
251
|
+
func httpRequest(urlst: String) {
|
252
|
+
|
253
|
+
var req = URLRequest(url: URL(string: urlst)!)
|
254
|
+
|
255
|
+
req.httpMethod = "GET"
|
256
|
+
|
257
|
+
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
|
258
|
+
|
259
|
+
DispathQueue.main.async {
|
260
|
+
|
261
|
+
self.alert(msg: "接続失敗")
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
})
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
})
|
270
|
+
|
271
|
+
let cancel: UIAlertAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
|
272
|
+
|
273
|
+
alert.addAction(cancel)
|
274
|
+
|
275
|
+
present(alert: true, completion: nil)
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
func alert(msg: String) {
|
282
|
+
|
283
|
+
let alert = UIAlertController(title: nil, message: msg, preferredStyle: .alert)
|
284
|
+
|
285
|
+
let cancel: UIAlertAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
|
286
|
+
|
287
|
+
alert.addAction(cancel)
|
288
|
+
|
289
|
+
present(alert: true, completion: nil)
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
```
|
1
省略していた関数alertの中身を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -201,3 +201,29 @@
|
|
201
201
|
このように、いろいろ試してみましたが、アラートは表示されませんでした。
|
202
202
|
|
203
203
|
解決への糸口をご存じの方がいらっしゃれば、よろしくお願いいたします。
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
### 追記
|
208
|
+
|
209
|
+
alert関数の中身はこんな感じになっています。
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
```swift
|
214
|
+
|
215
|
+
func alert(msg: String) {
|
216
|
+
|
217
|
+
let alert = UIAlertController(title: nil, message: msg, preferredStyle: .alert)
|
218
|
+
|
219
|
+
let cancel: UIAlertAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
|
220
|
+
|
221
|
+
alert.addAction(cancel)
|
222
|
+
|
223
|
+
present(alert: true, completion: nil)
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
```
|