2016-12-04 5 views
0

申し込みのセクションを作成しようとしましたが、申し込みをクリックすると何もしないようです。私は部分的に私の知識とそれを構築するためのチュートリアルを使用しましたが、それをクリックすると何も起こりません。iOSアプリが応答しないための登録ページ

ログを確認して何かが出てきたかどうかを確認しましたが、何も表示されませんでした。私はXcodeとSwiftを初めて使うので、愚かな間違いをしたかどうかはわかりませんが、私のコードはここにあります。

Google plistとpodもインストールされているので、問題はないと思います。

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:. 
} 


} 
+0

にねえ武、あなたは正しく '作成' IBActionにUIButtonを接続よろしいですか? – AndreasLukas

+0

UIButtonがCreate IBActionに接続されていることを100%確信しています。Create IBActionの隣の黒い点にマウスを移動し、Create UIButtonをハイライト表示します。 – Moo

+0

Create()の先頭に印刷して、メソッドが呼び出されたかどうかを確認してから報告してください。 – AndreasLukas

答えて

1

ユーザーサインインしようとしているのではなく、ユーザーがサインアップしているように思えます。

変更

FIRAuth.auth()?.signIn(withEmail: Email, password: Password, completion: { (user, error) in

FIRAuth.auth()?.createUser(withEmail: Email, password: Password, completion: { (user, error) in

+0

ありがとうございました!以前に私が見逃していたことは分かりませんでした。 – Moo

+0

理論上はそうすべきだが、今は壊れていることが他にあるかどうかはわからない。私の答えがあなたのためにこれを解決するかどうか確認できますか?それは他の多くの事柄である可能性がありますが、これは現時点で最も明白でした。 –

+0

うん、それは完璧に動作します!その1つの正確な間違いだった! – Moo

関連する問題