私はSwift(そして一般的なプログラミング)を使い慣れています。私はログイン機能でXcodeにいくつかの困難を抱えています。私が望むのは、エラーが返されず、ユーザーが別のコントローラーに送られなければならない場合、ユーザーはログインする必要があるということです。私はAppleからのドキュメントとperformSegueWithIdentifier
(もちろんいくつかの質問はここで尋ねられました)を読んだことがありますが、識別子が与えられたpush
またはmodal
のセグを使用してもまだ動作しません。アプリがクラッシュするか、資格情報が間違っていてもUITabBarController
にユーザーが送られます。ViewController segueとlogin
これは私のLogInViewController.swiftです:
@IBAction func loginAction(sender: AnyObject)
{
if self.emailField.text == "" || self.passwordField.text == ""
{
let alertController = UIAlertController(title: "Oops!", message: "Please enter an email and password.", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
else
{
FIRAuth.auth()?.signInWithEmail(self.emailField.text!, password: self.passwordField.text!) { (user, error) in
if error == nil
{
self.emailField.text = ""
self.passwordField.text = ""
}
else
{
let alertController = UIAlertController(title: "Oops!", message: error?.localizedDescription, preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
// User Logged in
self.performSegueWithIdentifier("LoggedIn", sender: self)
}
}
}
私はコンソールで取得エラー:
2016年9月4日14:55:30.019 DrinkApp [37777:1006336] ** *未知の例外 'NSGenericException'のためアプリを終了します、理由: 'Segue' LoggedIn 'のナビゲーションコントローラを見つけることができませんでした。プッシュセグは、ソースコントローラがUINavigationControllerのインスタンスによって管理されている場合にのみ使用できます。 'ここで
ありがとうございますが、私はまだそれを取得しません。 self.presentViewController:私はperformSegueWithIdentifier追加しました(alertController、アニメーション:真、完了を:ゼロ) } ユーザーは self.performSegueWithIdentifier( "LOGGEDIN"、送信者:自己)にログイン// しかし、私は、これを取得しますコンソール: 2016-09-04 14:20:56。968 DrinkApp [35936:985848] ***キャッチされていない例外 'NSGenericException'のためアプリを終了しています、理由: 'Segue' LoggedIn 'のナビゲーションコントローラが見つかりませんでした。プッシュセグは、ソースコントローラがUINavigationControllerのインスタンスによって管理されている場合にのみ使用できます。 ' – Joesoes