Cover and sheet not working on iOS 14.2 (Sim)
tscdl opened this issue ยท 6 comments
Hi, let me first say, I love your approach. ViewModifier stack plus array of routes representing it. That is the best and most solid approach I have seen. Really nice when refactoring code.
Problem found: I cannot get the sheets to work in iOS 14.2. It applies to the fullscreen cover, too โ however, not in 100% of cases. Problem applies to my own code, but also when I build your example code. Tested only in 14.2, not 14.x so far.
Regards
Thanks for raising this issue, I'm glad you like the library. I understand there was a bug in SwiftUI in iOS 14 that is fixed in iOS 14.5 upwards:
Resolved Issues
- You can now apply multiple sheet(isPresented:onDismiss:content:) and fullScreenCover(item:onDismiss:content:) modifiers in the same view hierarchy. (74246633)
I think it makes sense for this library to work around the issue; I'll have a look. Thanks!
Thanks for the quick reply!
Interesting. I just downloaded the 14.5 simulator runtime. In fact the problem disappears.
Unfortunately I hit issues when trying to work around this issue. For example, I tried variations on this theme to avoid chaining cover
and sheet
on the same view:
.cover(
isPresented: coverBinding,
onDismiss: nil,
content: { next }
)
.background(
Text("").hidden()
.sheet(
isPresented: sheetBinding,
onDismiss: nil,
content: { next }
)
)
That works around the issue on iOS 14.4 and below, but introduces a bug (even on iOS 15), where presenting a screen five layers of presentation deep fails with this error:
Attempt to present <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x7f9f3ef6c7d0> on <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x7f9f3f91af40> (from <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVVS_22_VariadicView_Children7ElementVS_24NavigationColumnModifier__: 0x7f9f3ef489d0>) which is already presenting <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x7f9f3ef5a6f0>
Instead, conditionally applying only one of the modifiers (#13) seems to work around the issue without introducing any regressions. Sadly, on iOS 14.4 and below, the Attempt to present
error still occurs when the number of presentation layers reaches five, but I think that may be a limitation/bug of SwiftUI.
I'll continue to check the solution works well before merging...
Thank you for the investigation @johnpatrickmorgan ๐๐ป
Thanks for solving it!