uiresponder
On iOS, if a superview’s userInteractionEnabled is NO, then all subviews are disabled as well?
You can override hitTest(_:withEvent:) to ignore the view itself, but still deliver touches to its subviews. class ContainerStackView : UIStackView { override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let result = super.hitTest(point, with: event) if result == self { return nil } return result } }
Dismiss keyboard with swipe gesture (as in Message app)
I created a UIView category that provides the desired functionality: https://github.com/danielamitay/DAKeyboardControl Edit: It has indeed been used on the app store.
UIGestureRecognizer receive touch but forward it to UIControl as well
Have you tried with this? cancelsTouchesInView A Boolean value affecting whether touches are delivered to a view when a gesture is recognized. @property(nonatomic) BOOL cancelsTouchesInView
How to get touches when parent view has userInteractionEnabled set to NO in iOS
To get a view to let touches pass-through but give its subviews handle touches, let userInteractionEnabled on that view to YES and, instead, use this snippet: -(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event { id hitView = [super hitTest:point withEvent:event]; if (hitView == self) return nil; else return hitView; } Source: http://cocoaheads.tumblr.com/post/2130871776/ignore-touches-to-uiview-subclass-but-not-to-its
Is there any way of asking an iOS view which of its children has first responder status? [duplicate]
I really like VJK’s solution, but as MattDiPasquale suggests it seems more complex than necessary. So I wrote this simpler version: Objective-C UIResponder+FirstResponder.h: #import <UIKit/UIKit.h> @interface UIResponder (FirstResponder) +(id)currentFirstResponder; @end UIResponder+FirstResponder.m: #import “UIResponder+FirstResponder.h” static __weak id currentFirstResponder; @implementation UIResponder (FirstResponder) +(id)currentFirstResponder { currentFirstResponder = nil; [[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil]; return currentFirstResponder; } -(void)findFirstResponder:(id)sender … Read more
InputAccessoryView docked at bottom
I was just shown “the” solution by Jason Foreman (@threeve). On your view controller (yes, view controller) add inputAccessoryView: and return the view you want to dock at the bottom and move with the keyboard. It just works. The view doesn’t actually need to be in your view hierarchy it will be inserted by the … Read more
How to ignore touch events and pass them to another subview’s UIControl objects?
Probably the best way to do this is to override hitTest:withEvent: in the view that you want to be ignoring touches. Depending on the complexity of your view hierarchy, there are a couple of easy ways to do this. If you have a reference to the view underneath the view to ignore: – (UIView *)hitTest:(CGPoint)point … Read more
UIGestureRecognizer blocks subview for handling touch events
I had a very similar problem and found my solution in this SO question. In summary, set yourself as the delegate for your UIGestureRecognizer and then check the targeted view before allowing your recognizer to process the touch. The relevant delegate method is: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch