当我按下提交按钮

时间:2018-01-15 05:52:17

标签: ios swift uinavigationcontroller

当我按下提交按钮时,应用程序将崩溃。在那个View Controller之前,我将隐藏导航控制器。从该视图控制器,我将显示导航控制器。我认为在使用导航控制器时出现问题。请帮我解决这个问题。

图片: Storyboard View

override func viewDidLoad() {
        super.viewDidLoad()

        //self.navigationController?.setNavigationBarHidden(false, animated: true)

        self.tfName.delegate = self
        self.tfPhone.delegate = self
        self.tfEmail.delegate = self
}

 override func viewDidAppear(_ animated: Bool)
    {
        super.viewDidAppear(true)

        //self.navigationController?.setNavigationBarHidden(false, animated: true)

        self.navigationItem.title = "Visitor Details"
}

@IBAction func btnSubmit(_ sender: Any)
    {
        if tfName.text! == "" || tfEmail.text! == "" || tfPhone.text == ""  || imgUser.image == UIImage(named: "chooseImage")
        {
            let alertController = UIAlertController.alertCtrl(title: "Warning", message: "Please fill all the fields correctly.", buttonTitle: "OK")
            self.present(alertController, animated: true, completion: nil)

            if !(Utility.validatePhone(value: tfPhone.text!))
            {
                let alertController = UIAlertController.alertCtrl(title: "Warning", message: "Please enter your phone number correctly.", buttonTitle: "OK")
                self.present(alertController, animated: true, completion: nil)

                if !(Utility.validateEmail(candidate: tfEmail.text!))
                {
                    let alertController = UIAlertController.alertCtrl(title: "Warning", message: "Please enter your email address correctly.", buttonTitle: "OK")
                    self.present(alertController, animated: true, completion: nil)
                }
            }
        }
        else
        {
            let confirmUserVC = self.storyboard?.instantiateViewController(withIdentifier: "ConfirmUserVC") as! ConfirmUserVC

            self.navigationController?.pushViewController(confirmUserVC, animated: true)
            //self.present(confirmUserVC, animated: true, completion: nil)

            confirmUserVC.strImg = self.imgUser.image!
            confirmUserVC.strName = tfName.text!
            confirmUserVC.strPhone = tfPhone.text!
            confirmUserVC.strEmail = tfEmail.text!
        }
}

控制台中显示错误:

  

2018-01-15 11:18:38.648960 + 0530 DE1 [5465:138738] [MC]懒加载   NSBundle MobileCoreServices.framework 2018-01-15 11:18:38.661549 + 0530   DE1 [5465:138738] [MC]已加载MobileCoreServices.framework 2018-01-15   11:18:38.683557 + 0530 DE1 [5465:138738] [MC]系统组容器   systemgroup.com.apple.configurationprofiles路径是   /Users/rahulchopra/Library/Developer/CoreSimulator/Devices/A51E4843-5A2C-4B97-837E-D30EDD015372/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles   2018-01-15 11:18:43.519861 + 0530 DE1 [5465:138738] [MC]阅读   私人有效用户设置。 2018-01-15 11:18:48.385343 + 0530   DE1 [5465:138738] [LayoutConstraints]无法同时满足   限制。可能至少有一个限制因素   以下列表是您不想要的。试试这个:(1)看看每一个   约束并试图找出你不期望的东西; (2)找到   添加了不需要的约束或约束并修复它的代码。   (       “”       “”       “   (有源)>”中,       “”)

     

将尝试通过违反约束来恢复      (有源)>

     

在UIViewAlertForUnsatisfiableConstraints处创建一个符号断点   在调试器中捕获它。方法中的   在UIView中列出的UIConstraintBasedLayoutDebugging类别    也可能有所帮助。 2018-01-15 11:18:48.386778 + 0530   DigiEntry [5465:138738] [LayoutConstraints]无法同时进行   满足约束。可能至少有一个限制因素   以下列表是您不想要的。试试这个:(1)看看每一个   约束并试图找出你不期望的东西; (2)找到   添加了不需要的约束或约束并修复它的代码。   (       “”       “”       “”       “   (有源)>”中,       “   (有源)>”中,       “   (有源)>”中,       “”)

     

将尝试通过违反约束来恢复      (有源)>

     

在UIViewAlertForUnsatisfiableConstraints处创建一个符号断点   在调试器中捕获它。方法中的   在UIView中列出的UIConstraintBasedLayoutDebugging类别    也可能有所帮助。 2018-01-15 11:18:50.587132 + 0530   DigiEntry [5465:138738]找不到支持类型5的键盘   键盘iPhone-PortraitChoco-PhonePad;运用   2024220450015396792_PortraitChoco_iPhone - 复合Pad_Default   2018-01-15 11:19:18.659275 + 0530 DigiEntry [5465:138738]   [LayoutConstraints]无法同时满足约束。     可能至少下列列表中的一个约束是一个   你不想要。试试这个:(1)看看每个约束并尝试   弄清楚你没想到的; (2)找到添加的代码   不需要的约束或约束并修复它。 (       “   (有源)>”中,       “”       “”       “”       “   (有源)>”中,       “”)

     

将尝试通过违反约束来恢复      (有源)>

     

在UIViewAlertForUnsatisfiableConstraints处创建一个符号断点   在调试器中捕获它。方法中的   在UIView中列出的UIConstraintBasedLayoutDebugging类别    也可能有所帮助。 2018-01-15 11:19:18.661432 + 0530   DigiEntry [5465:138738] [LayoutConstraints]无法同时进行   满足约束。可能至少有一个限制因素   以下列表是您不想要的。试试这个:(1)看看每一个   约束并试图找出你不期望的东西; (2)找到   添加了不需要的约束或约束并修复它的代码。   (       “”       “”       “”       “   (有源)>”中,       “   (有源)>”中,       “   (有源)>”中,       “”)

     

将尝试通过违反约束来恢复      (有源)>

     

在UIViewAlertForUnsatisfiableConstraints处创建一个符号断点   在调试器中捕获它。方法中的   在UIView中列出的UIConstraintBasedLayoutDebugging类别    也可能会有帮助。

0 个答案:

没有答案