2016-07-17 5 views
0

Ich habe gerade aktualisiert Xcode 7.3. Und wenn ich auf eine Schaltfläche oder ein Textfeld klicke, verschwinden alle Objekte in der Ansicht. Ich weiß nicht, warum das passiert oder was es verursacht hat. BTW: Ich kenne den Code, wenn ich den Knopf drücke, läuft, weil ich die Warnung sehe, die auftaucht. Auch die Ansicht verschwindet nicht, wenn ich auf die Schaltfläche "Habe kein Konto" klicke.Objekte in der Ansicht verschwinden, wenn Sie auf die Schaltfläche oder Textfelder tippen

The view

The view when I tap on the login button or either text field

Hier ist mein Code:

import UIKit 
import Firebase 
import Presentr 
import SWMessages 

class LoginViewController: UIViewController { 

    @IBOutlet weak var emailField: UITextField! 
    @IBOutlet weak var passwordField: HideShowPasswordTextField! 
    @IBOutlet weak var loginButton: UIButton! 


    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view. 

    } 

    override func viewWillAppear(animated: Bool) { 

     if ((FIRAuth.auth()?.currentUser) != nil) { 
     } else { 
     self.performSegueWithIdentifier("loginSegue", sender: nil) 
     } 
    } 

    @IBAction func didPressLogin(sender: AnyObject) { 
     func show() {} 
     loginButton.selected = true 
     if emailField.text == "" { 
      delay(2, closure: {() ->() in 
       func showFail() {} 
       self.loginButton.selected = false 
       let title = "Oops!" 
       let body = "You didn't enter an email!" 
       let controller = Presentr.alertViewController(title: title, body: body) 
       let tryAgainAction = AlertAction(title: "Try again", style: .Cancel){} 
       controller.addAction(tryAgainAction) 
       let presenter = Presentr(presentationType: .Alert) 
       self.customPresentViewController(presenter, viewController: controller, animated: true, completion: nil) }) 
     } else if passwordField.text == "" { 
      delay(2, closure: {() ->() in 
       func showFail() {} 
       self.loginButton.selected = false 
       let title = "Oops!" 
       let body = "You didn't enter a password!" 
       let controller = Presentr.alertViewController(title: title, body: body) 
       let tryAgainAction = AlertAction(title: "Try again", style: .Cancel){} 
       controller.addAction(tryAgainAction) 
       let presenter = Presentr(presentationType: .Alert) 
       self.customPresentViewController(presenter, viewController: controller, animated: true, completion: nil) }) 
     } else { 
      FIRAuth.auth()?.signInWithEmail(emailField.text!, password: passwordField.text!, completion: { (user, error) -> Void in 
       if error == nil { 
        func showSuccess() {} 
        self.loginButton.selected = false 
        self.performSegueWithIdentifier("loginSegue", sender: nil) 
       } else { 
        func showFail() {} 
        self.loginButton.selected = false 
        SWMessage.sharedInstance.showNotificationInViewController (self, title: "Oops!", subtitle: error?.localizedDescription, image: nil, type: .Error, duration: .Automatic, callback: nil, buttonTitle: "Try again", buttonCallback: {}, atPosition: .Top, canBeDismissedByUser: true) 
       } 
      }) 
     } 
    } 
    @IBAction func noAccount(sender: UIButton) { 
     // TODO: Decide whether to allow users to create an account or not. 

     UIApplication.sharedApplication().openURL(NSURL(string: "http://kalissaac.github.io/SmaLert")!) 
    } 

    /* 
    // MARK: - Navigation 

    // In a storyboard-based application, you will often want to do a little preparation before navigation 
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
     // Get the new view controller using segue.destinationViewController. 
     // Pass the selected object to the new view controller. 
    } 
    */ 

} 

// MARK: UITextFieldDelegate 
extension LoginViewController: UITextFieldDelegate { 
    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, textField string: String) -> Bool { 
     return passwordField.textField(textField, shouldChangeCharactersInRange: range, replacementString: string) 
    } 

    func textFieldDidEndEditing(textField: UITextField) { 
     passwordField.textFieldDidEndEditing(textField) 
    } 

    func textFieldShouldReturn(textField: UITextField) -> Bool { 
     textField.resignFirstResponder() 
     if textField == emailField { // Switch focus to other text field 
      passwordField.becomeFirstResponder() 
     } 
     return true 
    } 
} 

// MARK: HideShowPasswordTextFieldDelegate 
// Implementing this delegate is entirely optional. 
// It's useful when you want to show the user that their password is valid. 
extension LoginViewController: HideShowPasswordTextFieldDelegate { 
    func isValidPassword(password: String) -> Bool { 
     return password.characters.count > 6 
    } 
} 
+0

versuchen Sie, Super in 'viewWillApear (animiert: Bool)' aufzurufen. Können Sie auch den Code für die Methode 'customPresentViewController' anzeigen? – binchik

+0

@binchik Aufruf Super hat nicht geholfen. Der Code für CustomPresentViewController ist bereits vorhanden. (Es ist der Presentr Alarm-Controller) – CarvicheBlack

Antwort

0

ich dieses Problem gelöst, indem die benutzerdefinierte Klasse zu entfernen und erneut hinzufügen es. Das muss ein Fehler gewesen sein. Danke, dass du @binchik geholfen hast.

Verwandte Themen