Reputation: 9566
I want swipes to be detected on the lower half of the screen. That part of the screen can have UIButtons
as well. I want the swipes to take priority over the buttons (that is, if you swipe over the buttons, the buttons are ignored). But I want the buttons to work if you just tap on them.
I tried placing a transparent view over the buttons with the UISwipeGestureRecognizer
attached, but obviously that makes the the buttons not to work as it swallows all touches including taps.
I also tried placing the transparent view behind the buttons, but then the UIButton
event handling interferes with the swipe when you swipe over the button.
What's the best way to get this working?
I can think of a solution where the buttons would just be UIImageViews
with attached UITapGestureRecognizers
so you can then prioritize between the tap recognizers and the swipe recognizers.
But I'd like to keep the buttons as UIButtons
to take advantage of the highlighted stuff.
Upvotes: 2
Views: 722
Reputation: 23
i resolve same issue.
you just subclass UIButton and override 'touches~' method.
and then connect your customButton to it's parentView via some delegate.
Upvotes: 0
Reputation: 1137
You may try adding the UISwipeGestureRecognizer
to the superview of the UIButton
.
Upvotes: 3