|
I'm currently working on a SwiftUI project, and I've encountered an issue with a TabView inside a sheet. It seems that when I add ScrollView instances within the TabView, the ability to scroll down to dismiss the sheet is disabled.
In the above code, I have a ContentView that presents a sheet containing a TabView with two ScrollView instances. The issue is that when I open the sheet, I cannot scroll down to dismiss it. Instead, the scrolling is trapped within the ScrollView. If I remove the TabView then I can drag down to dismiss sheet from the ScrollView. Is there a way to allow scrolling down to dismiss the sheet while retaining the scroll functionality within TabView and ScrollView? |
|
Hi! You may want to add some padding to TabView so that touch gestures do not overlap each other. Below I have added some padding to TabView and you can dismiss the sheet as usual...
|
|
@ygeras, no. I want to dismiss the sheet from inside the ScrollView, not from the padding. As I mentioned, if you delete TabView and keep only the ScrollView, you can do it, but with the TabView, you can't. |
|
Just think this way. You placed following modifier to
or you can go ahead and write logic with complex gestures that would recognize what you want do to. |
|
As I already said, just remove the TabView and all will work as expected. Even with ScrollView. This is the native logic of iOS, and it's how many native apps work. So it's just a bug and I am looking for a solution.
|
|
It is not a bug, it is a contradictory gestures you are trying to use. TabView utilize swipe left and right gesture recognition and your dismiss also uses gesture recognizer to swipe it down, besides scroll also uses gesture recognizer to utilize its functions.
iOS devs cannot predict all the cases software developers are going to implement their way, and if you use contradictory actions it is not a bug. We do not see all the actions TabView and ScrollViews are utilizing for gesture recognition, but here it is obvious that those of tab view style and scroll view and sheet are in contradiction. In any case should you find a solution, you are more than welcome to post it here if no answer will be posted from someone on the forum. |
|
To further support my point, and maybe this helps you find your way to make some progress tackling the challenge, see the code below and maybe play with that to see what is happening.
|
|
OMG! The Also, as you said, TabView uses left and right swipe gesture recognition, so it shouldn't affect ScrollView's up and down gesture recognition, so it's definitely a bug. |
|
Good luck! I am not here to persaude you what to do. The way you answer seems like people here are obliged to provide right answers :)))) Besides removing |
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.