Reputation: 16793
I want to disable input pad on iphone when pressing 'done'. Any ideas about how to detect button press event?
Upvotes: 1
Views: 811
Reputation: 10353
Programatic Method
To register button press events you can either do the programmatic approach:
[button addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside]
Where buttonPressed: is a method in the class "self":
-(void)buttonPressed:(id)sender;
You can specify a pointer to any object instead of "self" of course, as long as the object has a buttonPressed: method.
Interface Builder
You can also use Interface Builder. Create a method that you want to execute:
-(IBAction)buttonPressed:(id)sender;
Then right click on the button in interface builder. You should see a list of actions. On the "touch up" action click on the circle button, and drag a connector to the object representing the class where you put the buttonPressed: method.
Disabling Input Pad
I'm not sure what you mean by this. Are you talking about dismissing a keyboard input? If so, you have to call the "resignFirstResponder:" method. Say, for example, the keyboard pops up because you are editing a text field. To dismiss the keyboard call the following method on the text field:
[textField resignFirstResponder];
Upvotes: 3