Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect a swipe vs tap #97

Closed
MaxHasADHD opened this issue Nov 4, 2020 · 1 comment
Closed

Detect a swipe vs tap #97

MaxHasADHD opened this issue Nov 4, 2020 · 1 comment
Labels

Comments

@MaxHasADHD
Copy link

Is it possible to detect when the page changes from a swipe instead of a tap?

@marcosgriselli
Copy link
Owner

@MaxHasADHD SwipeableTabBarController is a subclass of UITabBarController so it comes with the same mechanisms. You can use KVO to observe the selectedViewController or selectedIndex properties that will change when swiping ends. Or if you're using Combine you can do it with publishers:

publisher(for: \.selectedIndex).sink { newIndex in
    print("New index: \(newIndex)")
}.store(in: &cancellables)
publisher(for: \.selectedViewController).sink { newValue in
    print("New view controller: \(newValue)")
}.store(in: &cancellables)

I'm closing this since its not a library-specific issue but a UITabBarController question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants