Githubにpushしていますので、見ていただければ幸いです。
① StartVC内のFacebookSDKログインボタンをタップし、ログインします。
② FirstVCに遷移します。左上ボタンをタップし、SlideVCを開きます。
③ ログアウトボタンをタップし、ダイアログの[ログアウト]をタップし、①に戻ります。
この一連の流れを、先日からコードを見直しながら100回はRUNして挙動をチェックしていますが、
③を実行後、たまに①に戻らずに②の状態になる事が分かりました。(①のStartVC表示後すぐに②のFirstVCへモーダル遷移する)
全体を通してやはり、その状態があったり無かったりと不安定ですので、
原因を調べてはいるのですが、なかなか分かりません。
不具合に当たる箇所をご指摘いただければ助かります。
よろしくお願いします。
③に当たるSlideVC内です import UIKit import Firebase import FirebaseAuth import GoogleSignIn import FBSDKCoreKit import FBSDKLoginKit class LeftMenuViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let button = UIButton() //表示されるテキスト button.setTitle("ログアウト", for: .normal) //テキストの色 button.setTitleColor(UIColor.blue, for: .normal) //タップした状態の色 button.setTitleColor(UIColor.red, for: .highlighted) //サイズ button.frame = CGRect(x: 0,y: 0,width: 400,height: 100) //タグ番号 button.tag = 1 //配置場所 view.center = CGPoint(x:100, y:100) //ボタンをタップした時に実行するメソッドを指定 button.addTarget(self, action: #selector(self.LogOutButton), for:.touchUpInside) view.addSubview(button) } //ログアウトボタン @objc func LogOutButton(sender: Any) { let alertController = UIAlertController(title: "ユーザーのお名前",message: "・・をログアウトしてもよろしいですか?", preferredStyle: UIAlertControllerStyle.alert) // ②-1 OKボタンの実装 let okAction = UIAlertAction(title: "ログアウト", style: UIAlertActionStyle.destructive){ (action: UIAlertAction) in //アラートが消えるのと画面遷移が重ならないように0.5秒後に画面遷移するようにしてる DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { //ログアウト遷移 let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let nextView = storyboard.instantiateViewController(withIdentifier: "Start") as! StartViewController self.present(nextView, animated: true, completion: nil) print("ログアウトしました") } let loginManager : FBSDKLoginManager = FBSDKLoginManager() loginManager.logOut() self.dismiss(animated: true, completion: nil) } //CANCELボタンの実装 let cancelButton = UIAlertAction(title: "キャンセル", style: UIAlertActionStyle.cancel, handler: nil) //③-1 ボタンに追加 alertController.addAction(okAction) //③-2 CANCELボタンの追加 alertController.addAction(cancelButton) //④ アラートの表示 present(alertController,animated: true,completion: nil) } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。