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

Presenting view controller from detached view controller is not supported #1

Open
gregbci opened this issue Sep 24, 2024 · 0 comments

Comments

@gregbci
Copy link

gregbci commented Sep 24, 2024

Hello,

Thanks for making this example, I found it very helpful! I was getting the following error in Xcode 15.4 when sheets or fullScreenCovers were displayed on a page:

Presenting view controller <_TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_: 0x103019800> from detached view controller <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x10481a400> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x10481a400> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release.

The root cause is applying the .sheet() and .fullScreenCover() modifiers to the page rather than the NavigationStack:

NavigationStack(path: $coordinator.path) {
   coordinator.build(page: .main)
   .navigationDestination(for: AppPages.self) { page in
      coordinator.build(page: page)
   }  
}  <---- applied to navigation stack
.sheet(item: $coordinator.sheet) { sheet in
   coordinator.buildSheet(sheet: sheet)
}               
.fullScreenCover(item: $coordinator.fullScreenCover) { item in
   coordinator.buildCover(cover: item)
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant