在此处输入图像描述我需要创建启用用户交互的按钮或标签。我们可以创建它吗?当用户点击文本字段外时,我尝试禁用文本字段。但无法完成。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
{
let currentCellDescriptor = getCellDescriptorForIndexPath(indexPath)
let cell:ArrowCell = tableView.dequeueReusableCell(withIdentifier: "\(idString)") as! ArrowCell
cell.currentMinimumValueTextField.delegate = self
cell.currentaximumvaluextield.delegate = self
cell.currentMinimumValueTextField.isEnabled = false
cell.currentaximumvaluextield.isEnabled = false
}
func textFieldDidBeginEditing(_ textField: UITextField) {
textField.isEnabled = true
print("TextField did begin editing method called")
}
func textFieldDidEndEditing(_ textField: UITextField) {
print("TextField did end editing method called\(textField.text!)")
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder();
return true;
}
提前致谢
谢谢回复。我找到了一个使用文本字段委托的解决方案。在文本字段外部单击时,我禁用了文本字段。使用这种方法,我可以在文本字段中编辑和显示滑块值。
func textFieldDidEndEditing(_ textField: UITextField)
{
if (textField.tag == 1){
let min = textField.text
print(min)
appDelegate.updatedsliderprice = true
appDelegate.pricesliderlowerValue = Double(min!)!
}
else
{
let max = textField.text
print(max)
appDelegate.updatedsliderprice = true
appDelegate.pricesliderupperValue = Double(max!)!
}
rangeSliderValueChanged(RangeSliderValue: rangeSlider)
tableView.reloadSections(IndexSet(integer: 2), with: UITableViewRowAnimation.fade)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句