Post

Replies

Boosts

Views

Activity

Navigation + Tabview + Sheet broken in iOS 15
It looks like Navigation + TabView + Sheet is broken in iOS 15. When I do this: ContentView -> DetailView -> Bottom Sheet When the bottom sheet comes up, the Detail view is automatically popped off the stack: https://www.youtube.com/watch?v=gguLptAx0l4 I expect the Detail view to stay there even when the bottom sheet appears. Does anyone have any idea on why this happens and how to fix it? Here is my sample code: import SwiftUI import RealmSwift struct ContentView: View { var body: some View { NavigationView { TabView { TabItemView(num: 1) .tabItem { Text("One") } TabItemView(num: 2) .tabItem { Text("Two") } } } } } struct TabItemView: View { private let num: Int init(num: Int) { self.num = num } var body: some View { NavigationLink(destination: DetailView(text: "Detail View \(num)")) { Text("Go to Detail View") } } } struct DetailView: View { @State private var showingSheet = false private let text: String init(text: String) { self.text = text } var body: some View { Button("Open Sheet") { showingSheet.toggle() }.sheet(isPresented: $showingSheet) { Text("Sheet Text") } } } This works on iOS 14.
1
0
815
Dec ’21
Navigation + Tabview + Sheet broken in iOS 15
It looks like Navigation + TabView + Sheet is broken in iOS 15. When I do this: ContentView -> DetailView -> Bottom Sheet When the bottom sheet comes up, the Detail view is automatically popped off the stack: https://www.youtube.com/watch?v=gguLptAx0l4 I expect the Detail view to stay there even when the bottom sheet appears. Does anyone have any idea on why this happens and how to fix it? Here is my sample code: import SwiftUI import RealmSwift struct ContentView: View { var body: some View { NavigationView { TabView { TabItemView(num: 1) .tabItem { Text("One") } TabItemView(num: 2) .tabItem { Text("Two") } } } } } struct TabItemView: View { private let num: Int init(num: Int) { self.num = num } var body: some View { NavigationLink(destination: DetailView(text: "Detail View \(num)")) { Text("Go to Detail View") } } } struct DetailView: View { @State private var showingSheet = false private let text: String init(text: String) { self.text = text } var body: some View { Button("Open Sheet") { showingSheet.toggle() }.sheet(isPresented: $showingSheet) { Text("Sheet Text") } } } This works on iOS 14.
Replies
1
Boosts
0
Views
815
Activity
Dec ’21