I have tabView that presents multiple tabs . in home view i have navigationView that has search button as navigationitem,that pushes to search view . inside the search view after presenting a sheet and dismissing it, searchView gets pop to home view and pushed again to top. and this causes the interface of search being misplaces. here is my code for tabView:
struct ContentView: View { var body: some View { TabView { homeView() .tabItem { Text("Home") } } } } here is the code for HomeView:
struct homeView:View{ @State var showSearch:Bool = false var body: some View{ NavigationView{ Text("home") .navigationBarTitle("", displayMode: .inline) .navigationViewStyle(StackNavigationViewStyle()) .navigationBarItems(trailing: HStack{ NavigationLink.init("", destination: SearchContentView(), isActive: $showSearch) Button.init("search", action: { showSearch.toggle() })}) } } } and then this is searchView:
struct SearchContentView: View { @State private var isplayItem:Bool = false @State private var isEditing:Bool = false var body: some View { List(0..<30, rowContent: { i in Text("\(i)th") .onTapGesture { isplayItem.toggle() } .sheet(isPresented: self.$isplayItem) { Text("search Item \(i)") .background(Color.blue) .offset(x: 0, y: 0) } }) .navigationBarTitle("search", displayMode: .inline) .navigationViewStyle(StackNavigationViewStyle()) } } thanks in advance.