I have a view overlayed on top of many other views. I am only using the overaly to detect some number of touches on the screen, but other than that I don't want the view to stop the behavior of other views underneath, which are scrollviews, etc. How can I forward all the touches through this overlay view? It is a subcalss of UIView.
相关问题
- Stop child process when parent process stops
- Fire resize event once not based on timing
- Unable to change UISearchBar cancel button title c
- C# CS0079 Event Handling Compile Errors
- Google Maps event listeners not working properly i
相关文章
- What does it means in C# : using -= operator by ev
- How are custom broadcast events implemented in Jav
- Programming a touch screen application with SWING
- How many pixels are scrolled on a website with a m
- Difference Between RoutedEventHandler and EventHan
- Why are my UIView layer properties not being set w
- Wait for function till user stops typing
- WPF- validation error event doesn't fire
Improved version of @fresidue answer. You can use this
UIView
subclass as transparent view passing touches outside its subview. Implementation in Objective-C:and in Swift:
Try something like this...
The code above, in your touchesBegan method for example would pass the touches to all of the subviews of view.
As suggested by @PixelCloudStv if you want to throw touched from one view to another but with some additional control over this process - subclass UIView
//header
//implementation
After in interfaceBuilder just set class of View to TouchView and set active rect with your rect. Also u can change and implement other logic.
This is an old thread, but it came up on a search, so I thought I'd add my 2c. I have a covering UIView with subviews, and only want to intercept the touches that hit one of the subviews, so I modified PixelCloudSt's answer to
I had a similar issue with a UIStackView (but could be any other view). My configuration was the following:
It's a classical case where I have a container that needed to be placed in the background, with buttons on the side. For layout purposes, I included the buttons in a UIStackView, but now the middle (empty) part of the stackView intercepts touches :-(
What I did is create a subclass of UIStackView with a property defining the subView that should be touchable. Now, any touch on the side buttons (included in the * viewsWithActiveTouch* array) will be given to the buttons, while any touch on the stackview anywhere else than these views won't be intercepted, and therefore passed to whatever is below the stack view.
Just an update, in Swift 4.0 and above this worked for me: