Touchable area moves when view presents sheet on appear #1949
Replies: 2 comments
-
UPD: Solution 3 |
Beta Was this translation helpful? Give feedback.
-
This is a long standing SwiftUI bug. https://developer.apple.com/forums/thread/718495 I do have a workaround for this bug, but it isn’t pretty. I use a custom UIHostingController subclass that uses swizzling to override the dismiss behaviour and post an NSNotification. I can then observe that so that 200ms after dismiss is called (or the keyboard dismisses as this can also trigger the bug), I invalidate the view frame for the presented and hosting controller by setting it back to its current value. The whole thing is wrapped up behind a custom generic SwiftUI view controller representable view that embeds its content (from a view builder closure) in the custom hosting controller and presents it that way. I can then use this to wrap any sheet exhibiting this bug. I told you it isn’t nice! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The strange bug I caught where the tappable area moves, after presenting the sheet right after the view appears. Here is the code which I use for testing:
I found 2 solutions, how to fix this:
.presentationDetents([.fraction(0.999)])
to theSheetView()
. Available ios 16, but we need io14+.Only both are unacceptable.
Beta Was this translation helpful? Give feedback.
All reactions