Reputation: 16276
The frame where the UISearchBar
is drawn is the following:
UISearchBar *sBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 280, 40)];
Simply i want to dismiss the keyboard when the user click on ANY area than the area defined above.
Is there any UISearchBar
delegate method to do so, or a simple way. Thanx in advance.
Upvotes: 2
Views: 809
Reputation: 13458
You'll need to handle click/touch events on the other views in your window, and call:
if (sBar.isFirstResponder)
[sBar resignFirstResponder];
sBar will need to be a property of your UIViewController
To handle touch events, add these to your UIViewController:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
- (void) touchesMoved:(NESet *)touches withEvent:(UIEvent *)event
{
}
- (void) touchesEnded:(NESet *)touches withEvent:(UIEvent *)event
{
}
- (void) touchesCancelled:(NESet *)touches withEvent:(UIEvent *)event
{
}
and call [sBar resignFirstResponder] from at least the touchesBegan method.
Upvotes: 1