Closed HackShitUp closed 6 years ago
@HackShitUp do you have a sample project I can check out? I might have a solution to test on this particular case but I don't have the time to build a demo example.
@HackShitUp any update?
@marcosgriselli Sorry for the late response, I've been busy starting up. I'll try to share a sample project as soon as I can, and post the Git URL here.
@marcosgriselli https://github.com/HackShitUp/SwipeIssue
I checked it out and this quick fix will be good until I come back home in a couple days.
On your extension TableViewController: UICollectionViewDataSource, UICollectionViewDelegate
add
override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
setTabBarSwipe(enabled: false)
}
override func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
setTabBarSwipe(enabled: true)
}
This will disable the SwipeableTabBarController interaction when using a UIScrollView
and reactivate it when you finish using it.
I'll come up with a solution integrated to the library next week.
@marcosgriselli Perfect, I completely forgot about the scroll view delegate methods. Thank you!
@marcosgriselli I tried your solution and it sometimes work and sometimes doesn't. After a certain time the app gets stuck and the views start overlapping.
@moazkh60 Are you customizing the tabBar?
No but I have two collection view in my screen, one is horizontal and one is vertical, so I need to disable the swipe when my horizontal collection view is being scrolled. When I do this using the above mentioned methods of scrollView it works the first time and as soon as I lift the finger up and try again it's stuck. If I try to move to some other tab and come back the screen starts to overlap.
@moazkh60 Can you expand on the 'it's stuck' part? Do you mind building a simple demo project?
Stuck like I can't scroll the collection view anymore or click on any item in the collection view but I am able to click other tabs at the tab bar and move to some other screen when I return back the swipe able controller starts to overlap the screens and now the screen that got stuck is just plain white because the view of that screen is now overlapped to some other screen. Ok I will try to replicate the issue in a sample project and let you know.
@marcosgriselli I have replicated the issue. Please check my replicated issue project on GitHub using this link SwipeableTabBarController screen overLap issue replicated
Thanks @moazkh60. I'll be checking this tonight.
Thanks. I will be waiting for your response.
@marcosgriselli did you check?
@moazkh60 I was just checking it, the app crashes when trying to move to the second viewController on the SwipeableTabBar, there's something wrong with the Storyboard outlets. Can you fix them and push?
@marcosgriselli I just cloned the repo and tried again the app is crashing on second screen because you forgot to install the pods. Please install the pods using pod Install and open the project using xcworkspace not xcproj
Thanks.
I think you didn't download properly. Here is the link https://github.com/moazkh60/SwipeableTabBarController-ReplicatedIssue/blob/master/SwipeableTabBarController-ReplicatedIssue/SecondTabVC.swift
Got it, not sure why it wasn't appearing on the project. Ok so found a solution 🎉. Check it out:
I'll be updating the library during the next weekend when I have some extra time to work out a generic solution so I don't introduce any 'hacky fixes'.
Just as an exception you could edit the pod's SwipeInteractor's
UIGestureRecognizerDelegate
to look like this:
// MARK: - UIGestureRecognizerDelegate
extension SwipeInteractor: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if let collectionView = otherGestureRecognizer.view as? UICollectionView {
if let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
if flowLayout.scrollDirection == .horizontal {
return false
}
}
}
if gestureRecognizer == panRecognizer {
if let point = panRecognizer?.translation(in: panRecognizer?.view?.superview) {
return fabs(point.x) < InteractionConstants.xTranslationForRecognition
}
}
return true
}
}
The issue is resolved to some extent but it's still there. I think when I swipe fast then the screen starts to overlap. Try installing the issue app on mobile and do some stress testing moving horizontal scrolling on second screen and then moving between all the tabs using swipe gesture a bit fast. You will see the issue.
@moazkh60 You are right. This will need deeper revision as it's a complicated issue. It's triggered by UIPercentDrivenTransition
calling a start transition method again before finishing the previous one. I'll go over it in the weekend.
Thanks @marcosgriselli I will be waiting.
@marcosgriselli any updates?
@marcosgriselli did you resolve the issue yet ? Let me know if it gets resolved soon otherwise I would have no other option but to remove the library from my project.
Hi @moazkh60, I've been super busy with work and another library I released. I haven't had the time to look into this yet. I plan to fix this but I don't have an approximate milestone date. I'll keep the issue open to keep you or anyone else interested posted.
@marcosgriselli I am still waiting for your update I am dependent on your library now. I know you might be busy but please try to find some time to resolve this issue. I would really appreciate it. Thanks for the effort and thanks for the awesome library.
When will you resolve this issue. I'm stuck in my development of app due to this issue. I have to disable several features. Kindly provide the fix. @marcosgriselli
@marcosgriselli thanks for the update finally 👍. Now the issue is resolved to some extent. Whenever I run the app the first time and try to swipe immediately same issue of white screen occurs. But on the second run it works fine. Kindly look into that thanks.
@moazkh60 second run meaning you close the app and run it again? I have an idea to solve this. Are you convining version 1.0.10
and the code for supporting horizontal UICollectionView's
from above?
@marcosgriselli yes I close the app and run it again. No I am on a different page when my app starts, so horizontal UICollectionView is not above. Few points to be noted
@marcosgriselli any further updates?
I'm closing this issue as it drifted away from the original issue. I have more time to delicate to open source projects now so issues will be tackled a lot faster. @moazkh60 if you're still using this library feel free to create any new issue with a good description and we'll solve it :)
Is it possible to traverse this protocol for a UIView instead of a UIViewController? I have a UITableViewCell with a horizontal scrolling UICollectionView in it and it seems to conflict with the UIPangesture (I'm assuming) so it swipes between the UITabBarController's view controllers instead of scrolling through the UICollectionView in the UITableViewCell.