gpt4 book ai didi

ios - 当我们在 IOS 10.2 中滑过它时,UISwitch 不工作

转载 作者:行者123 更新时间:2023-11-28 15:46:43 26 4
gpt4 key购买 nike

我一直收到这个错误,当我滑过我的开关时,它的状态“开”和“关”在运行 iOS 10.2 的手机上不起作用。但是,当我单击它时,相同的开关会使其状态正确调用。我用运行 iOS 9.3 的手机对其进行了交叉检查。在滑动手指或单击时,这两种状态都可以正常工作。这是 iOS 10.2 的一个小错误还是我的代码有问题(我不这么认为,因为它在 9.3 中可以正常工作)

我的代码

  @IBAction func Switch_clicked(sender: AnyObject)
{
if switch_btn.on
{

print("button on")
self.EnableTouchID()

}


else
{

print("button off")
self.DisableTouchID()


}

}

注意:主要问题是开关在没有调用 .on 或 .off 状态的情况下滑动到“ON”或“OFF”

最佳答案

试试这个:

检查调用 IBAction 方法的 UISwitch事件类型。它必须是 valueChanged

enter image description here

@IBAction func onChangeSwitchState(_ sender: UISwitch)
{
if sender.isOn
{
print("button on")

}
else
{
print("button off")
}
}

关于ios - 当我们在 IOS 10.2 中滑过它时,UISwitch 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42919171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com