2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SwiftUI】混ぜるな危険

Last updated at Posted at 2023-05-08

親Viewで検索バーを使う
  +
子ViewのnavigationBarTitleDisplayMode.inlineにする
  +
子ViewのtoolbarBackground.hidden
  +
親Viewで何かしら検索をかけた状態で、子Viewに遷移する
  ↓
遷移した先でスワイプで戻ろうとして、やっぱやめたってすると、一生戻れなくなる

画面収録_2023-05-08_15_59_59_AdobeExpress.gif

struct HogeView: View {
    @State var text: String = ""
    
    var body: some View {
        NavigationStack {
            ScrollView {
                NavigationLink {
                    Text("Detail View")
                        .toolbarBackground(.hidden, for: .navigationBar)
                        .navigationBarTitleDisplayMode(.inline)
                } label: {
                    Text("navigate")
                }
            }
            .searchable(text: $text)
        }
    }
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?