[Using Xcode 15.3 with Simulator running iPhone 15, iOS 17.4]
I’m seeing what I feel is odd conduct with searchable in a NavigationStack. Code beneath is an instance that exhibits the difficulty.
After I navigate to a view from a NavigationStack after which navigate again, the search bar seems. Moreover, if there isn’t a navigation title on the NavigationStack, the search bar seems instantly.
I do not plan on not utilizing navigation titles. It simply appears odd to me and I do not perceive the connection between the title or navigation and the search bar.
//
// ContentView.swift
// NavigationSearchTest
//
import SwiftUI
///
struct StringView: View
{
let string: String
var physique: some View
{
Textual content(string)
.navigationTitle("String")
}
}
///
struct ContentView: View
{
let strings = ["String 1", "String 2", "String 3"]
@State var searchText: String = ""
var physique: some View
{
NavigationStack
{
Listing
{
ForEach(strings, id: .self)
{
s in
NavigationLink(vacation spot: StringView(string: s))
{
Textual content(s)
}
}
}
.searchable(textual content: $searchText)
#if false // If false, search bar seems instantly
.navigationTitle("Strings")
#endif
}
}
}
#Preview {
ContentView()
}