Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable a UIButton?

I am working on a project in which I have to show all photos of Photo Library in a plist and show them horizontally on UIButtons.

My app will also have an edit button: when the user clicks this button, a delete mark (such as usually appears in other iPhone/iPad apps) should show on each button.

But here's the crucial bit: as soon as this delete mark appears, the functionality of the button should be disabled. I've tried accomplishing this with the following:

{   editbutton.enabled=NO; } 

...but it neither produces an error nor works. What should I do?

like image 358
Rahul Avatar asked Jun 02 '11 05:06

Rahul


People also ask

How do I disable UI button?

The quickest way to disable the button in Swift is to simply set the button's isEnabled property to false. For example button. isEnabled = false.

How can I check if UIButton is pressed?

If you want to check If UIButton is Pressed or not, You should handle TouchDown Handler and change button's state to pressed in touchDown hadnler. You can track ToucUpInside method to Change state of button to Not-pressed again.

How do I disable a button in Xcode?

To disable a button, you should use the disabled view modifier. It takes bool parameter, which for example, can be taken from the state. You can use the disabled modifier on a view above buttons ( VStack , for example). That way, you will apply it to all buttons (or other controls below).


1 Answers

Please set this...

 editButton.userInteractionEnabled = NO;  

or You can use

 editButton.enabled = NO; 
like image 144
Mehul Mistri Avatar answered Sep 24 '22 00:09

Mehul Mistri