Search code examples
iosobjective-cuigesturerecognizergestureuicontrol

Make UIControl only accept swipe gestures and pass along touch/tap gestures


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!


Solution

  • 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.