teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

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

2019/05/23 05:10

投稿

rabupon
rabupon

スコア24

title CHANGED
File without changes
body CHANGED
@@ -1,179 +1,149 @@
1
- ### 前提・実現したいこと
1
+ ### 実現したいこと
2
-
3
- 画面でIDとパスワードを入力し、特定URLにてログインチェック。
2
+ 画面でIDとパスワードを入力し、URLにてログインチェック。ログインOKは、メッセージを表示後画面遷移、NGは、メッセージを表示のみ
4
- ログインOKの場合は、メッセージを表示後、画面遷移
5
- ログインNGの場合は、メッセージを表示後、特に何もしない
6
-
7
- ### 発生している問題・エラーメッセージ
3
+ ### 発生している問題
8
- 表示された画面に特に何もせず(初期値としてセットセットされている値)
9
- 、ボタンだけタップすると正常に動作します。
4
+ 表示された画面(初期値)で、ボタンだけタップすると正常に動作します。(OKの場合もNGの場合も)
10
- ログインOKの場合もログインNGの場合も
11
- しかし、テキストフィールドの「tno」にカーソルを移動した後(特に値も変更しなくても)に
5
+ 「tno」にカーソルを移動した後(特に値も変更しなくても)にボタンをタップすると以下のエラーになります。
12
- ボタンをタップすると以下のエラーになります。
13
- webを参考にストーリーボードの以下のボタン等の接続を確認し、問題ないようでしたが
14
- 再度作成しなおしてみたりしましたが、変わりません・・
6
+ webを参考にボタン等の接続を再度作成しましたが、変わりません。
15
7
  ```
8
+ 【テキストに移動したとき】
9
+ 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
10
+ ap_name[7387:347170] [MC] Reading from private effective user settings.
11
+ 【登録ボタンタップ時】
12
+ ap_name[7387:347834] [Assert] Cannot be called with asCopy = NO on non-main thread.
13
+ 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=(
14
+ 0 UIKitCore 0x000000010cd22932 kFixedAnimationDuration_block_invoke_5 + 107
15
+ 1 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
16
+ 2 libdispatch.dylib 0x00000001054fc83d _dispatch_once_callout + 66
17
+ 3 UIKitCore 0x000000010cd228c5 +[UIView(Animation) setAnimationsEnabled:] + 76
18
+ 4 UIKitCore 0x000000010cd22a13 +[UIView(Animation) performWithoutAnimation:] + 84
19
+ 5 UIKitCore 0x000000010c6ed51b +[UIRemoteKeyboardWindow remoteKeyboardWindowForScreen:create:] + 418
20
+ 6 UIKitCore 0x000000010c6d6a3a -[UIPeripheralHost(UIKitInternal) inputViews] + 100
21
+ 7 UIKitCore 0x000000010c6dbf46 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 167
22
+ 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211
23
+ 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608
24
+ 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
25
+ 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
26
+ 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172
27
+ 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150
28
+ 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407
29
+ 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13
30
+ 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294
31
+ 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
32
+ 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172
33
+ 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
34
+ 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68
35
+ 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688
36
+ 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227
37
+ 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12
38
+ 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
39
+ 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552
40
+ 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849
41
+ 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351
42
+ 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130
43
+ 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583
44
+ 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13
45
+ )
46
+ 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
47
+ ap_name[7387:347834] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
48
+ *** First throw call stack:
49
+ (
50
+ 0 CoreFoundation 0x00000001028b16fb __exceptionPreprocess + 331
51
+ 1 libobjc.A.dylib 0x00000001018b2ac5 objc_exception_throw + 48
52
+ 2 CoreFoundation 0x00000001028b1482 +[NSException raise:format:arguments:] + 98
53
+ 3 Foundation 0x0000000101300927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
54
+ 4 UIKitCore 0x000000010c6c6b0d -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 375
55
+ 5 UIKitCore 0x000000010c67fbda -[UIKeyboardImpl setDelegate:force:] + 1937
56
+ 6 UIKitCore 0x000000010c6d2b3f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1539
57
+ 7 UIKitCore 0x000000010c6dc0d2 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 563
58
+ 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211
59
+ 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608
60
+ 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
61
+ 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
62
+ 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172
63
+ 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150
64
+ 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407
65
+ 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13
66
+ 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294
67
+ 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
68
+ 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172
69
+ 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
70
+ 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68
71
+ 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688
72
+ 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227
73
+ 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12
74
+ 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8
75
+ 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552
76
+ 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849
77
+ 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351
78
+ 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130
79
+ 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583
80
+ 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13
81
+ )
16
82
  libc++abi.dylib: terminating with uncaught exception of type NSException
17
83
  ```
18
84
  ![ボタン](ec4b1a0d5ffb415e89c4631fd0dd74dc.png)
19
85
  ### 該当のソースコード
20
-
86
+ ```
21
87
  import UIKit
22
-
23
88
  class ViewAccount: UIViewController, UITextFieldDelegate {
24
-
25
- /*** AppDelegateクラスの共通変数を参照する ***/
26
- var app:AppDelegate = (UIApplication.shared.delegate as! AppDelegate)
27
- var seek_url:String?
28
- var wno:String = ""
29
- var wpass:String = ""
30
-
31
- @IBOutlet weak var tno: UITextField!
32
-
33
- @IBOutlet weak var tpass: UITextField!
34
-
35
- @IBOutlet weak var b_entry: UIButton!
36
-
37
- @IBOutlet weak var b_back: UIButton!
38
-
39
- override func viewDidLoad() {
40
- super.viewDidLoad()
41
- tno.delegate = self
42
- tpass.delegate = self
43
-
44
- tno.text = app.comon_member_id
45
- tpass.text = app.comon_member_pass
46
-
47
- }
48
-
49
-
50
- func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
51
- print("End")
52
- return true
53
- }
54
- //Returnキー入力後にキーボードを隠す
55
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
56
- textField.resignFirstResponder()
57
- return true
58
- }
59
-
60
-
61
- /************************************
62
- 登録ボタンクリック時
63
- ************************************/
64
- @IBAction func b_entry_tapped(_ sender: Any) {
65
- wno = tno.text!
66
- wpass = tpass.text!
67
-
68
- if CheckReachability(host_name: "google.com") {
69
- seek_url = app.main_url + "chk.php?id=" + wno + "&pass=" + wpass
70
-
71
- let url = URL(string: seek_url!)!
72
- let task = URLSession.shared.dataTask(with: url){ data, response, error in
73
- if let error = error{
74
- print(error.localizedDescription)
75
- return
76
- }
77
- var flg:Bool=false
78
-
79
- var status=0
80
- if let httpResponse = response as? HTTPURLResponse {
81
- status = httpResponse.statusCode
82
- }
83
-
84
- var msg = "";
85
- if status == 200{
86
- print("status",status)
87
-
88
- /*** 帰ってきたデータを文字列に変換 ***/
89
- let myData:NSString = NSString(data: data! as Data, encoding: String.Encoding.utf8.rawValue)!
90
- switch myData {
91
- case "OK_READY1":
92
- self.app.comon_member_id = self.wno
93
- self.app.comon_member_pass = self.wpass
94
- msg="登録しました。"
95
- flg=true
96
- break
97
- case "OK_READY2":
98
- self.app.comon_member_id = self.wno
99
- self.app.comon_member_pass = self.wpass
100
- msg="登録しました。"
101
- flg=true
102
- break
103
- default:
104
- msg="学籍番号またはパスワードが違います。"
105
- break
106
- }
107
-
108
- }else{
109
- msg="(***_)電波状態の良い場所でご利用ください。"
110
- flg=false
111
- }
112
-
113
-
114
- let title = "確認"
115
- let okText = "OK"
116
-
117
- let alert = UIAlertController(title: title, message: msg, preferredStyle: UIAlertControllerStyle.alert)
118
- let okayButton = UIAlertAction(title: okText, style: UIAlertActionStyle.default,
119
- handler:{
120
- (action: UIAlertAction!) -> Void in
121
-
122
- if(flg == true){
123
- /*** 端末に保存savMember_student ***/
124
- let ud = UserDefaults.standard
125
- ud.set(self.app.comon_member_id, forKey: "savMember_id")
126
- ud.set(self.app.comon_member_pass, forKey: "savMember_pass")
127
- /*** 設定画面に遷移 ***/
128
- var nex = UIViewController()
129
- var selfStoryboard: UIStoryboard?
130
- selfStoryboard = self.storyboard
131
- nex = selfStoryboard!.instantiateViewController(withIdentifier: "Conf") as UIViewController
132
- nex.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
133
- self.present(nex, animated: true, completion: nil)
134
- }
135
-
136
-
137
- })
138
- alert.addAction(okayButton)
139
- self.present(alert, animated: true, completion: nil)
140
-
141
- }
142
-
143
- task.resume()
144
-
145
-
146
-
147
-
148
- } else {
149
- let title = "確認"
150
- let message = "本アプリはインターネットに\n接続されていない状態で\n使用することは出来ません。";
151
- let okText = "OK"
152
-
153
- let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
154
- let okayButton: UIAlertAction = UIAlertAction(title: okText, style: UIAlertActionStyle.default, handler:{
155
- // ボタンが押された時の処理を書く(クロージャ実装)
156
- (action: UIAlertAction!) -> Void in
157
- print("インターネットに接続してください")
158
- })
159
- alert.addAction(okayButton)
160
-
161
- present(alert, animated: true, completion: nil)
162
- /*** アプリの強制終了 ***/
163
- //exit(0)
89
+ var seek_url:String?
90
+ @IBOutlet weak var tno: UITextField!
91
+ @IBOutlet weak var tpass: UITextField!
92
+ @IBOutlet weak var b_entry: UIButton!
93
+ override func viewDidLoad() {
94
+ super.viewDidLoad()
95
+ tno.delegate = self
96
+ tpass.delegate = self
97
+ tno.text = "aaa"
98
+ tpass.text = "pass"
99
+ }
100
+ // 登録ボタンクリック時
101
+ @IBAction func b_entry_tapped(_ sender: Any) {
102
+ seek_url = app.main_url + "chk.php?id=" + tno.text!+ "&pass=" + tpass.text!
103
+ let url = URL(string: seek_url!)!
104
+ let task = URLSession.shared.dataTask(with: url){ data, response, error in
105
+ //一部省略
106
+ var flg:Bool=false
107
+ var status=0
108
+ if let httpResponse = response as? HTTPURLResponse {
109
+ status = httpResponse.statusCode
110
+ }
111
+ var msg = "";
112
+ if status == 200{
113
+ let myData:NSString = NSString(data: data! as Data, encoding: String.Encoding.utf8.rawValue)!
114
+ switch myData {
115
+ case "OK_READY1":
116
+ msg="okay"
117
+ flg=true
118
+ break
119
+ default:
120
+ msg="NG"
121
+ break
164
122
  }
165
-
123
+ }else{
166
-
124
+ msg="error"
167
- }
125
+ }
168
-
126
+ let alert = UIAlertController(title: "確認", message: msg, preferredStyle: UIAlertControllerStyle.alert)
169
-
127
+ let okayButton = UIAlertAction(title: "OK", style: UIAlertActionStyle.default,
170
-
128
+ handler:{
129
+ (action: UIAlertAction!) -> Void in
130
+ if(flg == true){
131
+ var nex = UIViewController()
132
+ var selfStoryboard: UIStoryboard?
133
+ selfStoryboard = self.storyboard
134
+ nex = selfStoryboard!.instantiateViewController(withIdentifier: "Conf") as UIViewController
135
+ nex.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
136
+ self.present(nex, animated: true, completion: nil)
137
+ }
138
+ })
139
+ alert.addAction(okayButton)
140
+ self.present(alert, animated: true, completion: nil)
141
+ }
142
+ task.resume()
143
+ }
171
144
  }
145
+ ```
172
146
 
173
- ### 試したこと
147
+ ### バージョンなど
174
148
 
175
- ここに問題に対して試したこを記載してくださ
149
+ Xcode10です。ももとXcode7で作成していたものです
176
-
177
- ### 補足情報(FW/ツールのバージョンなど)
178
-
179
- ここにより詳細な情報を記載してください。