2017-08-17 70 views
3

在调试没有错误。代码不会进入下一个页面中的登录被接受后...帮助请为什么我的代码不进入下一个视图

if (emailValue == userEmail || passValue == userPassword) { 

    //store user information in the app to maintain session 

    let defaults = UserDefaults.standard 

    defaults.set(usernameValue, forKey: "usernameValue") 
    defaults.set(nameValue, forKey: "nameValue") 
    defaults.set(emailValue, forKey: "emailValue") 

    // Display Alert Message with confirmation 
    let myAlert = UIAlertController(title: "Success!", message: Constants.SucessMessages.EIRP, preferredStyle: UIAlertControllerStyle.alert); 
    let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.default){ action in 
     self.dismiss(animated: true, completion: nil); 
     if let navController = self.navigationController { 
      navController.popViewController(animated: true) 
     } 
    } 
    myAlert.addAction(okAction); 
    OperationQueue.main.addOperation { 
     self.present(myAlert, animated: true, completion: nil) 
    } 

} 
+0

其自带的内部确定行动 –

+0

@PAB PAB,要进入下一个画面,但你使用的代码是将先前的屏幕Ø okAction正水龙头 – Hooda

回答

3

你要进入下一个画面,但你使用的代码是将以往屏幕上的水龙头okAction

假设你的目标控制器的名字是DestinationViewController和使用的ID是DestinationVCID,以下选项可用于进入下一个画面,这取决于当前的用户。

代码用于您所使用的UIAlertAction,即okAction

if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DestinationVCID") as? DestinationViewController { 

     if let navigator = navigationController { 
      navigator.pushViewController(viewController, animated: true) 
     } 
} 

目前

if let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DestinationVCID") as? DestinationViewController 
{ 
    present(vc, animated: true, completion: nil) 
} 
+0

感谢真的BRO – Kenpachi

相关问题