【发布时间】:2017-06-14 09:47:14
【问题描述】:
在我的应用程序中,我有一个 UITextField 和 UIPickerView 作为下拉菜单,当用户点击文本字段时,他必须选择他的性别(男性或女性。我只想读取用户的值/字符串已在文本字段中选择。有人可以在这里帮助我吗
@IBAction func textChange(_ sender: UITextField) {
if userGenderTextField (Something has to here, Not sure what exactly)== "Male" {
print("Hello Sir")
} else {
print("Hello Madam")
}
}
【问题讨论】:
-
你可以使用 UITextField 的
.text方法。 -
if userGenderTextField.text == "Male"使用这个