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
UIView -- user interaction enabled false on parent but true on child?
That's correct, userInteractionEnabled set to NO on a parent view will cascade down to all subviews. If you need some subviews to have interaction enabled, but not others, you can separate your subviews into two parent views: one with userInteractionEnabled = YES and the other NO. Then put those two parent views in the main view.
How to pass the touch event to superview when userInteractionEnabled = YES?
You could try overriding the pointInside:withEvent:
method in your inner view. This will allow you to return NO when you want to forward touches to the superview:
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if( /* You have content, and you want to receive touches */){
return YES;
}else{
return NO;
}
}
Get touches when userinteractionenabled is NO
yes, because you disabled user interaction.
When you call super-hittest,the return from super-hittest depends on userInteraction property.
If it is enabled then only, it returns either itself or some subView.
If not enabled, it will always return nil.
On iOS, if a superview's userInteractionEnabled is NO, then all subviews are disabled as well?
You can't do that,
Instead you would change the arrangment of your views like following:
Main View -> subViews
To
Container View -> Main View that you want to set as inactive
-> other views that you want to still be active
So your current main view and you current subviews will become siblings, children of a new container view
iOS. How to pass touches to parent view of UIWebView
i found this article, which says:
There are different ways to capture touches over a Web View. One would be to extend the UIWebView class, but Apple says you should not, so we will stay away from that solution in case it causes problem later. Instead, we are going to extend the UIWindow class, and capture touch events before they get propagated to the correct view(s).
it continues to describe how this is done with sample code. see http://wyldco.com/blog/2010/11/how-to-capture-touches-over-a-uiwebview/ for more details.
Related Topics
Custom Rounding Corners on Uiview
Remove Println() for Release Version iOS Swift
iOS Swiftui: Pop or Dismiss View Programmatically
How to Send a Silent Push Notification Payload
Swift Error:Signal Sigabrt How to Solve It
Changing Text of Uibutton Programmatically Swift
Xcode 7 UI Testing: How to Dismiss a Series of System Alerts in Code
The Executable Gets Signed with Invalid Entitlements in Xcode
How to Load an Uiimage into a Swiftui Image Asynchronously
How to Detect One Button in Tableview Cell
Restoring Animation Where It Left Off When App Resumes from Background
Core Audio Offline Rendering Genericoutput
iPhone In-App Purchase Store Kit Error -1003 "Cannot Connect to Itunes Store"
Differencebetween Pan and Swipe in iOS
Application Crashed While Importing Songs from Ipod Library in iPhone for iOS 5.0