2014-09-02 100 views
-1

我正在第一次使用Swift在故事板上工作。 在應用程序的第一頁中,用戶將登錄,登錄成功完成後,用戶將導航到下一頁。 但是,當點擊按鈕時,首先導航發生在Web服務被調用之後,但我想要的是先驗證登錄Web服務,然後使用登錄數據導航到下一頁。在StoryBoard中執行Segue

我已經將登錄按鈕上的標識符,即故事板中按鈕上的「login_success」,並在登錄成功時調用self.performSegueWithIdentifier。

請指導我。謝謝。

回答

0

您可以在故事板中的標識符中添加segue。在文件所有者的故事板中設置segue。當我們得到服務器的響應,然後使用,

dispatch_async(dispatch_get_main_queue(), { 
if self.loginInfo.userEmail.length > 0{ 
self.performSegueWithIdentifier("login_success", sender: self) 
}   
}) 

在這裏,我檢查響應字符串是否有值。

然後調用segue的方法導航到下一頁。

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) 

{

if segue.identifier == "login_success" 

{

var mainVC: MainViewController! 
mainVC = segue.destinationViewController as MainViewController 
mainVC.mainLoginInfo = loginInfo 
} 
} 

MainViewController是我想在登錄成功後進行移動頁面。