swift - Disabling UIButton not working -


the solutions i'm finding on here use .enabled old, rather .isenabled.

so i'm currenting trying disable functionality/clickability of buttons if condition (or isn't) met. before disable them if condition isn't met if there on after (dynamically) met should theoretically enable. being said, not disabling buttons when start off .isenabled = false.

i know condition being met because have print statements , other tests (like labels being removedfromsuperview yet .isenabled = false buttons isn't working. encountered said problems or have solutions?

code below:

override func viewdidload() {     super.viewdidload()     trumpmoneydefault.setvalue(50, forkey: "trumpmoney")     print("unoviewcontroller")     //make buttons shouldn't clickable unlcickable     locklvl2.isenabled = false     locklvl3.isenabled = false     trumplvl2.isenabled = false     trumplvl3.isenabled = false     lvl2.isenabled = false     lvl3.isenabled = false      //make level2/3 unclickable defeault     //lvl2.isenabled = false     //lvl3.isenabled = false     //update trumpmoney label depending on if have enough cash     //also here check if have unlocked via purchase of unlock all. if so, skip     if trumpmoneydefault.value(forkey: "trumpmoney") != nil     {         trumpmoney.text = trumpmoneydefault.value(forkey: "trumpmoney") as? string          //remove locks if got money 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             }         }     } } 

really? should work.

1.)this how disable button , it's working.

mybutton.isenabled = false; 

2.)desperate way disable button disabling user interaction.

mybutton.isuserinteractionenabled = false;  

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -