skip to Main Content

The next code snippet is an example of the question.

import SwiftUI

struct TestingView: View {

  @State var myText = ""
  @State var myText2 = ""

  var body: some View {
     NavigationStack {
        Form {
            Text("Row 1")
            Text("Row 2")
            TextField("Write here", text: $myText)
            TextField("Write here too", text: $myText2)
        }
        .navigationTitle("Testing Toolbar") // delete if you want no title
        .navigationBarTitleDisplayMode(.inline)
        .toolbar {
            ToolbarItemGroup(placement: .keyboard) {
                Button {
                    print("Button up pressed")
                } label: {
                    Image(systemName: "chevron.up")
                }

                Button {
                    print("Button down pressed")
                } label: {
                    Image(systemName: "chevron.down")
                }
                Spacer()
            }
        }
    }

  }
 } 

struct TestingView_Previews: PreviewProvider {
   static var previews: some View {
      TestingView()
   } 
}

enter image description here

It works fine on iOS 16.4 or lower, but not on iOS 17. Any solution for iOS 17?

2

Answers


  1. Found a workaround: adding an empty navigation path to the NavigationStack solved the issue for me (so far).

    @State var path = NavigationPath()
    
    NavigationStack(path: $path) {
    ...
    }
    

    Credits to: https://stackoverflow.com/a/75756609/10603205

    Login or Signup to reply.
  2. It works on iOS 17+ devices and 16.0+ devices & simulators, but not on iOS 17 simulator. This is certainly a bug.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search