I currently have a view HostView that provides HostSummaryView and EditHostSummaryView, where the former responds to editMode.wrappedValue? == .inactive. HostView looks like this:
		struct HostView: View {
				@Environment(\.editMode) var editMode
				var body: some View {
						HStack {
								EditButton()
						}
						if editMode?.wrappedValue == .inactive {
								HostSummary()
						} else {
								EditHostSummary()
						}
				}
		}
I have a RootView that contains a TabView, which looks like this:
		struct RootView: View {
				@State private var selectedTab = 0
				var body: some View {
						TabView(selection: $selectedTab) {
								View1()
										.onTapGesture { self.selectedTab = 0 }
										.tag(0)
								View2()
										.tag(1)
								HostView()
										.tag(2)
						}
				}
		}
I tried passing the @Environment(\.editMode) var editMode to HostView, but that did not fix the problem. The EditButton does not toggle editMode in the HostView. However, HostView works when I access it through a non-TabView view.
How can I get this to work?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have these NavigationLinks generated like so:
NavigationView {
VStack {
	ForEach(listObject) { listObject in
	HStack{
			NavigationLink(destination: ListObjView()){
		Text("Nav")
	}.id(listObj.id)
}
}
}
}
When I access the ListObjView(), I'm unable to navigate back to home view. Is there anything that causes this?
Currently, if I try to type in a TextField nested twice within a List then Detail View, my app crashes with the error: Thread 1: signal SIGABRT and in the debugger (abbreviated):
CoreSimulator --- Device: iPhone 8 (---) - Runtime: iOS 14.4 (----) - DeviceType: iPhone 8
AttributeGraph precondition failure: invalid size for indirect attribute: 73 vs 1.
Here's the code that leads to this error.
		struct RootView {
				var body: some View {
						TabView {
								ListView()
										.tag(0)
						}
				}
		}
		struct ListView {
				@State var isActive = false
				var body: some View {
						NavigationView {
								NavigationLink(destination: DetailView(), isActive: $isActive)
						}
				}
		}
		struct DetailView {
				...
				var body: some View {
						TextField("Keyboard appears and the app crashes.", text: $text)
				}
		}
Is there a way around this? If I remove the TabView then it works just fine. I need the TabView though, so is there a way I can pop out of the TabView then render a Detail View outside of TabView?