【问题标题】:Disable An Interactive TextField When Clicking On Another TextField单击另一个文本字段时禁用交互式文本字段
【发布时间】:2020-12-03 01:33:47
【问题描述】:

我正在尝试这样做,以便当我单击一个文本字段并清除它时,我无法单击另一个。我的 TextFieldShouldReturn 函数中有这段代码,但它似乎不起作用。我怎样才能做到这一点,当我点击一个并清除它时,另一个被禁用?尝试制定解决方案。

if widthPer == textField {
        heightPer.isUserInteractionEnabled = false
        widthPer.isUserInteractionEnabled = true
    } else {
        heightPer.isUserInteractionEnabled = true
        widthPer.isUserInteractionEnabled = false
    }

【问题讨论】:

    标签: swift xcode uitextfield uitextfielddelegate


    【解决方案1】:

    我使用了它,它解决了我的问题。

      func textFieldShouldClear(_ textField: UITextField) -> Bool {
            if widthPer == textField {
                heightPer.isUserInteractionEnabled = false
                widthPer.isUserInteractionEnabled = true
            } else {
                heightPer.isUserInteractionEnabled = true
                widthPer.isUserInteractionEnabled = false
            }
            return true
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-18
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多