大佬教程收集整理的这篇文章主要介绍了swift – 禁用UIButton无法正常工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我正在尝试在某个条件满足(或不满足)的情况下禁用按钮的功能/可点击性.所以在它之前,如果条件不满足则禁用所有条件,然后如果在(动态)它满足之后,它理论上应该启用.话虽这么说,当我开始使用.isEnabled = false时,它最初不会禁用按钮.
我知道这个条件正在得到满足,因为@L_675_3@打印语句和其他测试(比如标签被删除了fromuperview还是.isEnabled = false因为按钮不起作用.有人遇到过这些问题或有任何解决方案吗?
代码如下:
override func viewDidLoad() { super.viewDidLoad() trumpMoneyDefault.SETVALue(50,forKey: "TrumpMoney") print("UnoViewController") //make all the buttons that shouldn't be clickable unlcickable locklvl2.isEnabled = false locklvl3.isEnabled = false trumplvl2.isEnabled = false trumplvl3.isEnabled = false lvl2.isEnabled = false lvl3.isEnabled = false //make level2/3 unclickable by defeault //lvl2.isEnabled = false //lvl3.isEnabled = false //update trumpmoney label depending on if they have enough cash //also here check if they have already unlocked all via purchase of unlock all. If so,then skip all this if trumpMoneyDefault.value(forKey: "TrumpMoney") != nil { trumpmoney.text = trumpMoneyDefault.value(forKey: "TrumpMoney") as? String //remove locks if they got the money by default. let tempTrumpMoneyDefault = trumpMoneyDefault.value(forKey: "TrumpMoney") as! Int if tempTrumpMoneyDefault >= 100 { locklvl2.removeFromSuperview() moneylvl2.removeFromSuperview() trumplvl2.removeFromSuperview() lvl2.isEnabled = true if tempTrumpMoneyDefault >= 500 { locklvl3.removeFromSuperview() moneylvl3.removeFromSuperview() trumplvl3.removeFromSuperview() lvl3.isEnabled = true } } } }
以上是大佬教程为你收集整理的swift – 禁用UIButton无法正常工作全部内容,希望文章能够帮你解决swift – 禁用UIButton无法正常工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。