Problem
I have a xib file with a UIImageView over the top of the background. I have it setup to resign when the user touches the background, but i cant figure out how to get the keyboard to resign if the user touches the UIImageView.
Question
What could I use to have the keyboard resign if they touch either the UIImageView OR the background?
Setup
There is an event set to listen for touch down on background that calls this method
- (IBAction)backgroundTap:(id)sender{
[userPassword resignFirstResponder];
[userLogin resignFirstResponder];
}
that works beautifully, but i’m not sure how to link up the UIImageView.
Make sure user interaction is disabled for the
UIImageView. Then touches on that element should be passed along to the underlying view. This effectively ignores taps on the image view entirely.Alternatively, if you want to capture taps on the image view for some other reason you could create a
UITapGestureRecognizerfor theUIImageViewwhose action is yourbackgroundTapmethod or some other method. (You might have to create a different method with an appropriate signature for use with the gesture recognizer, but your method above may be just fine.)