简体   繁体   中英

iPhone SDK make buttons unclickable/touchable

I have 3 buttons, when you click on any one of them, a corresponding UIImageView of a paper card pops up. In the interface builder the papercard is "in front" of the buttons so you can't see them when the card is visible (a good thing).

Problem is, I noticed that even though you can't see the buttons which are still behind the paper card UIImageView you still end up pressing those buttons if you click on the spot where they'd be, as though you're pressing right through the paper card.

So I need a function that will make those buttons untouchable while that paper card is visible, and remain untouchable until I hit the back button to remove the paper card and go back to the view three buttons. Is there such thing as a "disable button" code?

  • OK so google UIButton and you'll get to the docs here UIButton Class Reference .
  • Now scan the docs for anything that might work - (mmm nope)
  • Nope OK let's look at the superclass by following the link in the UIButton docs , which says the superclass is UIControl
  • Excellent there is a property called enabled - this looks like something you could use.

     self.myButton.enabled = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM