Open JMCPH opened 4 years ago
I don't think that's possible with the current API but it seems like a feature users will be interested since a lot of views would be better off ignoring that gesture (UICollectionView, MKMapView).
I can take a look at it in the upcoming weeks or help you out if you plan to draft a PR.
I would love to make a PR! :-)
Great, let me know if you need a hand with that. Ideally, we'll just find a way to select many views from different screens that will ignore the swiping gesture but I don't have a nice way of achieving that yet.
I'm thinking of turning this line:
private var panGestureRecognizer: UIPanGestureRecognizer!
Into this:
open var panGestureRecognizer: UIPanGestureRecognizer!
Then in the UITabBarController we can set the delegate of the panGestureRecognizer
to self
and then make the check in the following delegate function:
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive event: UIEvent) -> Bool {
return false // Based on the event touch view.
}
@marcosgriselli what do you think?
Sure, let's go that way. If we ever need to expand its use case we can search for another approach.
@JMCPH, @marcosgriselli maybe we should build upon that: https://github.com/marcosgriselli/SwipeableTabBarController/pull/103. And add new case none
to "AllowedSwipeDirection" enum and just return false for that case inside gestureRecognizerShouldBegin
method 🤷♂️
@borut-t I don't see a benefit on adding a none
swipe direction allowed since we already have a isSwipeEnabled
property for the tabBarController. This was originally planned for view controllers with views that required horizontal swiping and covered the entire screen like a map view.
We can extend views to have a property (associated object) that determines if swiping is enabled for that specific view and then check for it on gestureRecognizerShouldBegin
. In that way, we can have views that will trigger the transitions and views that won't on the same screen.
@borut-t I don't see a benefit on adding a
none
swipe direction allowed since we already have aisSwipeEnabled
property for the tabBarController. This was originally planned for view controllers with views that required horizontal swiping and covered the entire screen like a map view.We can extend views to have a property (associated object) that determines if swiping is enabled for that specific view and then check for it on
gestureRecognizerShouldBegin
. In that way, we can have views that will trigger the transitions and views that won't on the same screen.
Yeah, my bad.
Would it be possible to disable pan gesture for a specific UIView inside a UIViewController?
As the UIPanGestureRecognizer is private, it's not possible to do the following: