我試圖爲我的應用程序做一個註冊部分,但是,當我點擊註冊時,它似乎什麼都不做。我部分使用了我的知識和一個教程來構建它,但是當我點擊它時,什麼也沒有發生。iOS應用程序註冊頁面沒有響應
我檢查了我的日誌,看看是否有任何東西出現,但我根本沒有看到任何東西。我新使用Xcode和Swift,所以我不知道我是否犯了一個愚蠢的錯誤,但這裏是我的代碼。
我也有我的谷歌plist和豆莢安裝,所以我不認爲這是一個問題。
SignUpController.swift
import Foundation
import UIKit
import Firebase
import FirebaseAuth
import FirebaseDatabase
class SignUpController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var Email: UITextField!
@IBOutlet weak var Password: UITextField!
@IBAction func Create(_ sender: AnyObject) {
let Email = self.Email.text!
let Password = self.Password.text!
if Email != "" && Password != "" {
FIRAuth.auth()?.signIn(withEmail: Email, password: Password, completion: { (user, error) in
if error == nil{
FIREmailPasswordAuthProvider.credential(withEmail: Email, password: Password)
self.dismiss(animated: true, completion: nil)
}
print("Error")
})
}
else{
let alert = UIAlertController(title: "Error", message: "Enter email and password!", preferredStyle: .alert)
let action = UIAlertAction(title: "test", style: .default, handler: nil)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
func Cancel(_ sender: AnyObject) {
self.dismiss(animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
Email.delegate = self
Password.delegate = self
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}
AppDelegate.swift
import UIKit
import Firebase
import FirebaseDatabase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init() {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
}
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
@objc(applicationWillResignActive:) func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
嘿哞,你確定你正確連接的UIButton與 '創建' IBAction爲? – AndreasLukas
我100%確定我的UIButton連接到Create IBAction,我將鼠標移動到Create IBAction旁邊的黑點上,並突出顯示了創建UIButton。 – Moo
在Create()的開始處放置一個打印以查看該方法是否被調用,然後回報。 – AndreasLukas