Reputation: 1477
I'm developing an iOS 8.1 app for an iPhone 5 in Objective-C using Xcode 6.1.
When a UITextView
is clicked, I have an invisible UIControl
view that pops up just above the keyboard, so that the user can swipe down from above the keyboard and dismiss the keyboard (and then move the UIControl
out of view again). This is working fine. However, this UIControl
view that pops up above the keyboard is covering another UITextView
such that the covered text view cannot be tapped on. Every time I try to tap on the covered text view (which is visible because the UIControl
is not opaque), nothing happens because the UIControl
seems to just be taking the taps and not doing anything with them.
My question is, how do I make it so that the UIControl
simply ignores taps (letting them go straight through so that the UITextView
underneath can accept them), and yet accepts swipes (so that, when it is swiped downward, it can dismiss the keyboard and move out of view)?
I've tried several solutions but haven't found one that will work well for what I want.
Thanks!
Upvotes: 0
Views: 1215
Reputation: 2872
This question is similar to yours. Subclass your UIControl
and override - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
and call its super
variant to pass it up to its view.
Upvotes: 1
Reputation: 186
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
Use this event. If tap gesture return no.
Upvotes: 0
Reputation: 6899
There is another way to do this. Change the main view of your UIViewController
to a subclass of UIControl
instead of UIView
. Connect the following IBAction
to the view in order to dismiss the keyboard when the background is tapped.
- (IBAction)backgroundTapped{
[self.view endEditing:YES];
}
Apple Documentation - endEditing:
Upvotes: 0