问题描述
这是我拥有的UIBarButtonItem:
@IBAction func doneButtonPressed(_ sender: UIBarButtonItem) {
print("doneButton Pressed")
// Guard statement ensures that all fields have been satisfied,so that the JumpSpotAnnotation can be made,and no values are nil
guard let name = nameTextField.text,let estimatedHeight = estimatedHeightTextField.text,let locationDescription = descriptionTextView.text else {
nameRequiredLabel.isHidden = false
heightRequiredLabel.isHidden = false
descriptionRequiredLabel.isHidden = false
print("User did not put in all the required information.")
return
}
IBAction下它下面的代码是无关紧要的,因为这是一个保护问题。即使我将字面值设置为nil,它也不会触发。在我的viewDidLoad中,输入:
nameTextField.text = nil
estimatedHeightTextField.text = nil
descriptionTextView.text = nil
当我按下按钮时,在不更改这些文本的值的情况下,guard let语句仍然不会触发,并且下面的其余功能将执行。有什么想法吗?谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)