質問編集履歴

1

エラーをすべて追記しました(Consoleの内容です)一部文字数の関係上、ソース上削除したコードがあります

2019/05/23 05:10

投稿

rabupon
rabupon

スコア24

test CHANGED
File without changes
test CHANGED
@@ -1,32 +1,164 @@
1
- ### 前提・実現したいこと
2
-
3
-
4
-
5
- 画面でIDとパスワードを入力、特定URLにログインチェック。
6
-
7
- ログインOKの場合は、メッセージを表示後、画面遷移
8
-
9
- ログインNGの場合は、メッセ表示特にもしな
10
-
11
-
12
-
13
- ### 発生している問題・エラーメッセージ
14
-
15
- 表示され画面に特に何もせず(初期値してセットセットされている値)
16
-
17
- 、ボタンだけタップすると正常に動作します。
18
-
19
- ログインOKの場合もログインNGの場合も
20
-
21
- しかし、テキストフィールドの「tno」にカーソルを移動した後(特に値も変更しなくても)に
22
-
23
- ボタンをタップすると以下のエラーになります。
24
-
25
- webを参考にストーリーボードの以下のボタン等の接続を確認し、問題ないようでしたが
26
-
27
- 再度作成しなおしてみたりしましたが、変わりません・・。
28
-
29
- ```
1
+ ### 実現したいこと
2
+
3
+ 画面でIDとパスワードを入力し、URLにてログインチェック。ログインOKは、メッセージを表示後画面遷移、NGは、メッセージを表示のみ
4
+
5
+ ### 発生している問題
6
+
7
+ 表示された画面(初期値)で、ボタだけタップすると正常に動作します。(OKの場合もNGの場合も)
8
+
9
+ 「tno」にカソル移動した特に変更しなくても)にボタンをタップすると以下のエラーになります。
10
+
11
+ webを参考にボタン等の接続を再度作成しましたが、変わりません。
12
+
13
+ ```
14
+
15
+ 【テキストに移動したとき】
16
+
17
+ ap_name[7387:347170] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/tsuruta/Library/Developer/CoreSimulator/Devices/D4D69AA4-528C-4203-A8BD-C9006FB5697D/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
18
+
19
+ ap_name[7387:347170] [MC] Reading from private effective user settings.
20
+
21
+ 【登録ボタンタップ時】
22
+
23
+ ap_name[7387:347834] [Assert] Cannot be called with asCopy = NO on non-main thread.
24
+
25
+ ap_name[7387:347834] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(
26
+
27
+ 0 UIKitCore 0x000000010cd22932 kFixedAnimationDuration_block_invoke_5 + 107
28
+
29
+ 1 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
30
+
31
+ 2 libdispatch.dylib 0x00000001054fc83d _dispatch_once_callout + 66
32
+
33
+ 3 UIKitCore 0x000000010cd228c5 +[UIView(Animation) setAnimationsEnabled:] + 76
34
+
35
+ 4 UIKitCore 0x000000010cd22a13 +[UIView(Animation) performWithoutAnimation:] + 84
36
+
37
+ 5 UIKitCore 0x000000010c6ed51b +[UIRemoteKeyboardWindow remoteKeyboardWindowForScreen:create:] + 418
38
+
39
+ 6 UIKitCore 0x000000010c6d6a3a -[UIPeripheralHost(UIKitInternal) inputViews] + 100
40
+
41
+ 7 UIKitCore 0x000000010c6dbf46 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 167
42
+
43
+ 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211
44
+
45
+ 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608
46
+
47
+ 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
48
+
49
+ 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
50
+
51
+ 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172
52
+
53
+ 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150
54
+
55
+ 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407
56
+
57
+ 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13
58
+
59
+ 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294
60
+
61
+ 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
62
+
63
+ 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172
64
+
65
+ 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
66
+
67
+ 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68
68
+
69
+ 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688
70
+
71
+ 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227
72
+
73
+ 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12
74
+
75
+ 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
76
+
77
+ 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552
78
+
79
+ 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849
80
+
81
+ 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351
82
+
83
+ 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130
84
+
85
+ 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583
86
+
87
+ 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13
88
+
89
+ )
90
+
91
+ ap_name[7387:347834] *** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.103.12/Keyboard/UIKeyboardTaskQueue.m:453
92
+
93
+ ap_name[7387:347834] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
94
+
95
+ *** First throw call stack:
96
+
97
+ (
98
+
99
+ 0 CoreFoundation 0x00000001028b16fb __exceptionPreprocess + 331
100
+
101
+ 1 libobjc.A.dylib 0x00000001018b2ac5 objc_exception_throw + 48
102
+
103
+ 2 CoreFoundation 0x00000001028b1482 +[NSException raise:format:arguments:] + 98
104
+
105
+ 3 Foundation 0x0000000101300927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
106
+
107
+ 4 UIKitCore 0x000000010c6c6b0d -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 375
108
+
109
+ 5 UIKitCore 0x000000010c67fbda -[UIKeyboardImpl setDelegate:force:] + 1937
110
+
111
+ 6 UIKitCore 0x000000010c6d2b3f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1539
112
+
113
+ 7 UIKitCore 0x000000010c6dc0d2 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 563
114
+
115
+ 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211
116
+
117
+ 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608
118
+
119
+ 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
120
+
121
+ 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
122
+
123
+ 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172
124
+
125
+ 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150
126
+
127
+ 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407
128
+
129
+ 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13
130
+
131
+ 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294
132
+
133
+ 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
134
+
135
+ 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172
136
+
137
+ 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
138
+
139
+ 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68
140
+
141
+ 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688
142
+
143
+ 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227
144
+
145
+ 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12
146
+
147
+ 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
148
+
149
+ 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552
150
+
151
+ 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849
152
+
153
+ 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351
154
+
155
+ 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130
156
+
157
+ 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583
158
+
159
+ 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13
160
+
161
+ )
30
162
 
31
163
  libc++abi.dylib: terminating with uncaught exception of type NSException
32
164
 
@@ -36,322 +168,130 @@
36
168
 
37
169
  ### 該当のソースコード
38
170
 
39
-
171
+ ```
40
172
 
41
173
  import UIKit
42
174
 
43
-
44
-
45
175
  class ViewAccount: UIViewController, UITextFieldDelegate {
46
176
 
47
-
48
-
49
- /*** AppDelegateクラスの共通変数を参照する ***/
50
-
51
- var app:AppDelegate = (UIApplication.shared.delegate as! AppDelegate)
52
-
53
- var seek_url:String?
54
-
55
- var wno:String = ""
56
-
57
- var wpass:String = ""
58
-
59
-
60
-
61
- @IBOutlet weak var tno: UITextField!
62
-
63
-
64
-
65
- @IBOutlet weak var tpass: UITextField!
66
-
67
-
68
-
69
- @IBOutlet weak var b_entry: UIButton!
70
-
71
-
72
-
73
- @IBOutlet weak var b_back: UIButton!
74
-
75
-
76
-
77
- override func viewDidLoad() {
78
-
79
- super.viewDidLoad()
80
-
81
- tno.delegate = self
82
-
83
- tpass.delegate = self
84
-
85
-
86
-
87
- tno.text = app.comon_member_id
88
-
89
- tpass.text = app.comon_member_pass
90
-
91
-
92
-
93
- }
94
-
95
-
96
-
97
-
98
-
99
- func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
100
-
101
- print("End")
102
-
103
- return true
104
-
105
- }
106
-
107
- //Returnキー入力後にキーボードを隠す
108
-
109
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
110
-
111
- textField.resignFirstResponder()
112
-
113
- return true
114
-
115
- }
116
-
117
-
118
-
119
-
120
-
121
- /************************************
122
-
123
- 登録ボタンクリック時
124
-
125
- ************************************/
126
-
127
- @IBAction func b_entry_tapped(_ sender: Any) {
128
-
129
- wno = tno.text!
130
-
131
- wpass = tpass.text!
132
-
133
-
134
-
135
- if CheckReachability(host_name: "google.com") {
136
-
137
- seek_url = app.main_url + "chk.php?id=" + wno + "&pass=" + wpass
138
-
139
-
140
-
141
- let url = URL(string: seek_url!)!
142
-
143
- let task = URLSession.shared.dataTask(with: url){ data, response, error in
144
-
145
- if let error = error{
146
-
147
- print(error.localizedDescription)
148
-
149
- return
150
-
151
- }
152
-
153
- var flg:Bool=false
154
-
155
-
156
-
157
- var status=0
158
-
159
- if let httpResponse = response as? HTTPURLResponse {
160
-
161
- status = httpResponse.statusCode
162
-
163
- }
164
-
165
-
166
-
167
- var msg = "";
168
-
169
- if status == 200{
170
-
171
- print("status",status)
172
-
173
-
174
-
175
- /*** 帰ってきたデータを文字列に変換 ***/
176
-
177
- let myData:NSString = NSString(data: data! as Data, encoding: String.Encoding.utf8.rawValue)!
178
-
179
- switch myData {
180
-
181
- case "OK_READY1":
182
-
183
- self.app.comon_member_id = self.wno
184
-
185
- self.app.comon_member_pass = self.wpass
186
-
187
- msg="登録しました。"
188
-
189
- flg=true
190
-
191
- break
192
-
193
- case "OK_READY2":
194
-
195
- self.app.comon_member_id = self.wno
196
-
197
- self.app.comon_member_pass = self.wpass
198
-
199
- msg="登録しました。"
200
-
201
- flg=true
202
-
203
- break
204
-
205
- default:
206
-
207
- msg="学籍番号またはパスワードが違います。"
208
-
209
- break
210
-
211
- }
212
-
213
-
214
-
215
- }else{
216
-
217
- msg="(***_)電波状態の良い場所でご利用ください。"
218
-
219
- flg=false
220
-
221
- }
222
-
223
-
224
-
225
-
226
-
227
- let title = "確認"
228
-
229
- let okText = "OK"
230
-
231
-
232
-
233
- let alert = UIAlertController(title: title, message: msg, preferredStyle: UIAlertControllerStyle.alert)
234
-
235
- let okayButton = UIAlertAction(title: okText, style: UIAlertActionStyle.default,
236
-
237
- handler:{
238
-
239
- (action: UIAlertAction!) -> Void in
240
-
241
-
242
-
243
- if(flg == true){
244
-
245
- /*** 端末に保存savMember_student ***/
246
-
247
- let ud = UserDefaults.standard
248
-
249
- ud.set(self.app.comon_member_id, forKey: "savMember_id")
250
-
251
- ud.set(self.app.comon_member_pass, forKey: "savMember_pass")
252
-
253
- /*** 設定画面に遷移 ***/
254
-
255
- var nex = UIViewController()
256
-
257
- var selfStoryboard: UIStoryboard?
258
-
259
- selfStoryboard = self.storyboard
260
-
261
- nex = selfStoryboard!.instantiateViewController(withIdentifier: "Conf") as UIViewController
262
-
263
- nex.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
264
-
265
- self.present(nex, animated: true, completion: nil)
266
-
267
- }
268
-
269
-
270
-
271
-
272
-
273
- })
274
-
275
- alert.addAction(okayButton)
276
-
277
- self.present(alert, animated: true, completion: nil)
278
-
279
-
280
-
281
- }
282
-
283
-
284
-
285
- task.resume()
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
- } else {
296
-
297
- let title = "確認"
298
-
299
- let message = "本アプリはインターネットに\n接続されていない状態で\n使用することは出来ません。";
300
-
301
- let okText = "OK"
302
-
303
-
304
-
305
- let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
306
-
307
- let okayButton: UIAlertAction = UIAlertAction(title: okText, style: UIAlertActionStyle.default, handler:{
308
-
309
- // ボタンが押された時の処理を書く(クロージャ実装)
310
-
311
- (action: UIAlertAction!) -> Void in
312
-
313
- print("インターネットに接続してください")
314
-
315
- })
316
-
317
- alert.addAction(okayButton)
318
-
319
-
320
-
321
- present(alert, animated: true, completion: nil)
322
-
323
- /*** アプリの強制終了 ***/
324
-
325
- //exit(0)
177
+ var seek_url:String?
178
+
179
+ @IBOutlet weak var tno: UITextField!
180
+
181
+ @IBOutlet weak var tpass: UITextField!
182
+
183
+ @IBOutlet weak var b_entry: UIButton!
184
+
185
+ override func viewDidLoad() {
186
+
187
+ super.viewDidLoad()
188
+
189
+ tno.delegate = self
190
+
191
+ tpass.delegate = self
192
+
193
+ tno.text = "aaa"
194
+
195
+ tpass.text = "pass"
196
+
197
+ }
198
+
199
+ // 登録ボタンクリック時
200
+
201
+ @IBAction func b_entry_tapped(_ sender: Any) {
202
+
203
+ seek_url = app.main_url + "chk.php?id=" + tno.text!+ "&pass=" + tpass.text!
204
+
205
+ let url = URL(string: seek_url!)!
206
+
207
+ let task = URLSession.shared.dataTask(with: url){ data, response, error in
208
+
209
+ //一部省略
210
+
211
+ var flg:Bool=false
212
+
213
+ var status=0
214
+
215
+ if let httpResponse = response as? HTTPURLResponse {
216
+
217
+ status = httpResponse.statusCode
218
+
219
+ }
220
+
221
+ var msg = "";
222
+
223
+ if status == 200{
224
+
225
+ let myData:NSString = NSString(data: data! as Data, encoding: String.Encoding.utf8.rawValue)!
226
+
227
+ switch myData {
228
+
229
+ case "OK_READY1":
230
+
231
+ msg="okay"
232
+
233
+ flg=true
234
+
235
+ break
236
+
237
+ default:
238
+
239
+ msg="NG"
240
+
241
+ break
326
242
 
327
243
  }
328
244
 
329
-
245
+ }else{
246
+
330
-
247
+ msg="error"
331
-
332
-
248
+
333
- }
249
+ }
250
+
334
-
251
+ let alert = UIAlertController(title: "確認", message: msg, preferredStyle: UIAlertControllerStyle.alert)
252
+
335
-
253
+ let okayButton = UIAlertAction(title: "OK", style: UIAlertActionStyle.default,
254
+
336
-
255
+ handler:{
256
+
337
-
257
+ (action: UIAlertAction!) -> Void in
258
+
338
-
259
+ if(flg == true){
260
+
339
-
261
+ var nex = UIViewController()
262
+
263
+ var selfStoryboard: UIStoryboard?
264
+
265
+ selfStoryboard = self.storyboard
266
+
267
+ nex = selfStoryboard!.instantiateViewController(withIdentifier: "Conf") as UIViewController
268
+
269
+ nex.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
270
+
271
+ self.present(nex, animated: true, completion: nil)
272
+
273
+ }
274
+
275
+ })
276
+
277
+ alert.addAction(okayButton)
278
+
279
+ self.present(alert, animated: true, completion: nil)
280
+
281
+ }
282
+
283
+ task.resume()
284
+
285
+ }
340
286
 
341
287
  }
342
288
 
343
-
289
+ ```
344
-
290
+
291
+
292
+
345
- ### 試したこと
293
+ ### バージョンなど
346
-
347
-
348
-
294
+
295
+
296
+
349
- ここに問題に対して試したこを記載してくださ
297
+ Xcode10です。ももとXcode7で作成していたものです
350
-
351
-
352
-
353
- ### 補足情報(FW/ツールのバージョンなど)
354
-
355
-
356
-
357
- ここにより詳細な情報を記載してください。