実現したいこと
画面でIDとパスワードを入力し、URLにてログインチェック。ログインOKは、メッセージを表示後画面遷移、NGは、メッセージを表示のみ
発生している問題
表示された画面(初期値)で、ボタンだけタップすると正常に動作します。(OKの場合もNGの場合も)
「tno」にカーソルを移動した後(特に値も変更しなくても)にボタンをタップすると以下のエラーになります。
webを参考にボタン等の接続を再度作成しましたが、変わりません。
【テキストに移動したとき】 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 ap_name[7387:347170] [MC] Reading from private effective user settings. 【登録ボタンタップ時】 ap_name[7387:347834] [Assert] Cannot be called with asCopy = NO on non-main thread. 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=( 0 UIKitCore 0x000000010cd22932 kFixedAnimationDuration_block_invoke_5 + 107 1 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8 2 libdispatch.dylib 0x00000001054fc83d _dispatch_once_callout + 66 3 UIKitCore 0x000000010cd228c5 +[UIView(Animation) setAnimationsEnabled:] + 76 4 UIKitCore 0x000000010cd22a13 +[UIView(Animation) performWithoutAnimation:] + 84 5 UIKitCore 0x000000010c6ed51b +[UIRemoteKeyboardWindow remoteKeyboardWindowForScreen:create:] + 418 6 UIKitCore 0x000000010c6d6a3a -[UIPeripheralHost(UIKitInternal) inputViews] + 100 7 UIKitCore 0x000000010c6dbf46 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 167 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13 ) 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 ap_name[7387:347834] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.' *** First throw call stack: ( 0 CoreFoundation 0x00000001028b16fb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x00000001018b2ac5 objc_exception_throw + 48 2 CoreFoundation 0x00000001028b1482 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000101300927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194 4 UIKitCore 0x000000010c6c6b0d -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 375 5 UIKitCore 0x000000010c67fbda -[UIKeyboardImpl setDelegate:force:] + 1937 6 UIKitCore 0x000000010c6d2b3f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1539 7 UIKitCore 0x000000010c6dc0d2 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 563 8 UIKitCore 0x000000010c271b4d -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1211 9 UIKitCore 0x000000010c27385a -[UIViewController _presentViewController:withAnimationController:completion:] + 4608 10 UIKitCore 0x000000010c27611b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98 11 UIKitCore 0x000000010c276633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511 12 UIKitCore 0x000000010c276082 -[UIViewController _presentViewController:animated:completion:] + 172 13 UIKitCore 0x000000010c2762e0 -[UIViewController presentViewController:animated:completion:] + 150 14 ap_name 0x00000001007d995f $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 3407 15 ap_name 0x00000001007da05d $s11ap_name11ViewAccountC14b_entry_tappedyyypFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 13 16 ap_name 0x00000001007a9ab6 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 294 17 CFNetwork 0x0000000105c4b178 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19 18 CFNetwork 0x0000000105c61c56 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 172 19 Foundation 0x0000000101367412 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7 20 Foundation 0x000000010136731a -[NSBlockOperation main] + 68 21 Foundation 0x00000001013641f4 -[__NSOperationInternal _start:] + 688 22 Foundation 0x0000000101369f5b __NSOQSchedule_f + 227 23 libdispatch.dylib 0x00000001054f9d7f _dispatch_call_block_and_release + 12 24 libdispatch.dylib 0x00000001054fadb5 _dispatch_client_callout + 8 25 libdispatch.dylib 0x00000001054fdc95 _dispatch_continuation_pop + 552 26 libdispatch.dylib 0x00000001054fd08f _dispatch_async_redirect_invoke + 849 27 libdispatch.dylib 0x000000010550b632 _dispatch_root_queue_drain + 351 28 libdispatch.dylib 0x000000010550bfca _dispatch_worker_thread2 + 130 29 libsystem_pthread.dylib 0x00000001058e36b3 _pthread_wqthread + 583 30 libsystem_pthread.dylib 0x00000001058e33fd start_wqthread + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException
該当のソースコード
import UIKit class ViewAccount: UIViewController, UITextFieldDelegate { var seek_url:String? @IBOutlet weak var tno: UITextField! @IBOutlet weak var tpass: UITextField! @IBOutlet weak var b_entry: UIButton! override func viewDidLoad() { super.viewDidLoad() tno.delegate = self tpass.delegate = self tno.text = "aaa" tpass.text = "pass" } // 登録ボタンクリック時 @IBAction func b_entry_tapped(_ sender: Any) { seek_url = app.main_url + "chk.php?id=" + tno.text!+ "&pass=" + tpass.text! let url = URL(string: seek_url!)! let task = URLSession.shared.dataTask(with: url){ data, response, error in //一部省略 var flg:Bool=false var status=0 if let httpResponse = response as? HTTPURLResponse { status = httpResponse.statusCode } var msg = ""; if status == 200{ let myData:NSString = NSString(data: data! as Data, encoding: String.Encoding.utf8.rawValue)! switch myData { case "OK_READY1": msg="okay" flg=true break default: msg="NG" break } }else{ msg="error" } let alert = UIAlertController(title: "確認", message: msg, preferredStyle: UIAlertControllerStyle.alert) let okayButton = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler:{ (action: UIAlertAction!) -> Void in if(flg == true){ var nex = UIViewController() var selfStoryboard: UIStoryboard? selfStoryboard = self.storyboard nex = selfStoryboard!.instantiateViewController(withIdentifier: "Conf") as UIViewController nex.modalTransitionStyle = UIModalTransitionStyle.crossDissolve self.present(nex, animated: true, completion: nil) } }) alert.addAction(okayButton) self.present(alert, animated: true, completion: nil) } task.resume() } }
バージョンなど
Xcode10です。もともとXcode7で作成していたものです

回答1件
あなたの回答
tips
プレビュー