将isTouchInside设置为false

问题描述 投票:0回答:1

我需要检查UITextField是否已经收到某种焦点,例如isTouchInside然后在执行if语句中的代码后我想将isTouchInside设置为false。这可能吗?或者在这里应该使用其他东西?

我想在用户选择文本字段时为数组添加3个不同的值。当我这样做时,触摸txt1,然后触摸txt2。 txt 1也被添加到数组中,我不希望这种情况发生

if self.txt1.isTouchInside{ //this sets isTouchInside to true
    print("txt1 touched")
    self.array.append(value1)
    //how to set isTouchInside to false here?

 }else if self.txt2.isTouchInside{
    print("txt2 touched")
    self.array.append(value2)
    //how to set isTouchInside to false here?
 }else if self.txt3.isTouchInside{
    print("txt3 touched")
    self.array.append(value3)
   //how to set isTouchInside to false here?
}
ios swift
1个回答
0
投票

这是一个只读属性。你无法改变isTouchInside的值。完全停止。不可能。

解释你想要在更高层次上完成什么,也许我们可以帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.