2016-03-26 17 views
0

Yalnızca bir kullanıcı tarafından oluşturulan bir kullanıcı kapatılırken, bir kullanıcı tarafından oluşturulan bir kullanıcı kapatılıyor ve bir önceki başlangıç ​​vc'ye dönülüyor.bir vC denetleyicisini bir FIREBASE_REF bloğundan kapatarak hızlıca kaydırma

Şu anda var:

// Attempt to create a new user. (authData = dictionary). 
     FIREBASE_REF.createUser(email, password: password, withValueCompletionBlock: { (error, authData) in 

// If there was no error then 
      if error == nil { 
// Authorise the new user into the application. (authData = object). 
       FIREBASE_REF.authUser(email, password: password, withCompletionBlock: { (error, authData) in 

        if error == nil { 
// Store the user id into the device. 
         NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid") 
// Stop the activity indicator. 
         self.activityInd.stopAnimating() 
// Close the create user screen. 
         self.dismissViewControllerAnimated(true, completion: nil) 
        } 
        else 
        { 
// Stop the activity indicator. 
         self.activityInd.stopAnimating() 

         print(error) 

        } 
       }) 
      } 
      else 

// USER ACCOUNT ALREADY EXISTS \\ 
      { 
// Stop the activity indicator. 
       self.activityInd.stopAnimating() 

// Display an error message. 
       let alertController = UIAlertController(title: "USER DUPLICATION ERROR", message: 
        "user account already exists, login as normal", preferredStyle: UIAlertControllerStyle.Alert) 
       alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil)) 
       self.presentViewController(alertController, animated: true, completion: nil) 

// Close the create user screen. 
       self.dismissViewControllerAnimated(true, completion: nil) 

      } 
     }) 

Kullanıcı daha sonra başlangıçtaki vc yeni self.dismissViewController mükemmel çalışıyor hesabı ve getiri oluşturur ve ana yükler. Ancak, zaten mevcut bir kullanıcı olduğunda self.dismissViewController bir şey yapmaz. Eğer bu konuda biraz ışık tutabilirse, bu çok takdir edilecektir. Ayrıca, herhangi biri, uyarı iletisinin kullanıcının vc'yi kapatmadan önce görevden alınmasını seçinceye kadar ekranda kalmasını nasıl sağladığına dair öneride bulunabilir. Herkes ben sorunu bitmedi heres nasıl ilgi ise

Teşekkür

+0

ben indirdim ettik, ben uyarı mesajı açıklama, bu ekran kapanır ve gerektiği gibi döndürür. Açıkçası, uyarı mesajının soruna neden olması durumunda, bu sorunun neden bu konuda bana neden olduğunu söyleyebilirim. Uyarı çağrıldıktan sonra kodda artık devam etmediğinden şüpheleniyorum. – dacrozz

cevap

0

Sorun çözüldü:

// USER ACCOUNT ALREADY EXISTS \\ 
      { 
// Stop the activity indicator. 
       self.activityInd.stopAnimating() 

// Display an error message. 
       let refreshAlert = UIAlertController(title: "USER DUPLICATION ERROR", message: "user account already exists, login as normal.", preferredStyle: UIAlertControllerStyle.Alert) 

       refreshAlert.addAction(UIAlertAction(title: "Dismiss", style: .Default, handler: { (action: UIAlertAction!) in 
// Close the create user screen. 
        self.dismissViewControllerAnimated(true, completion: nil) 
       })) 

       self.presentViewController(refreshAlert, animated: true, completion: nil) 
      } 
     }) 
İlgili konular