views:

58

answers:

3

In my application, there is one button in the navigation bar. I want it to work only for the 1t click of the user. If he continousally presses on it 2 or 3 times just after the 1st click the button shouldnt recieve the following ones. How can I do this?

My app always crashes if the user presses it for more than once. I dont want to make it multithread and use lock. Thats why i want to know whether there is anyother alternative.

+2  A: 

(If the app crashes by pressing more than once then there's a bigger problem.)

Since the button is on the navigation bar, that's a UIBarButtonItem, not a UIButton. The UIBarButtonItem has an enabled property which you can set to NO to disable the button.

(If it is really a UIButton, don't worry, it also has an enabled property.)

KennyTM
As u said it was a much bigger problem than disabling the button. So i went and found out the error. Thanks a lot for the comment. Otherwise i wud have sticked to disabling the button so to do it fast rather than looking for the error. Also button disabling was working perfectly.
wolverine
A: 

After the user clicked the button, you could set the "enabled" property to NO and after the action finished, set it back to YES

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html#//apple_ref/occ/instp/UIControl/enabled

schaechtele
A: 

Luckily this is pretty easy to do. The UIBarItem class has an enabled property. Just set it to NO once the user taps it.

bpapa