Placing the toolbar above keyboard does not work in iOS 17
Asked Answered
A

2

10

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?

Amass answered 5/10, 2023 at 14:34 Comment(8)
Works for me on iPhone (ios-17), but the toolbar does not show on iPad (iPadOS-17) the first time I open the App. However, closing the App on iPad, then selecting it again shows the toolbar with the "chevrons" that work. On MacOS 14.1, Xcode 15.1, tested on real devices (not Previews).Graff
I'm seeing this too, on iPhone 13 Pro running iOS 17.0.3.Mannish
I have the same issue on my iPhone 13 Pro (works for iOS16.4, but with iOS 17 so far).Umpire
Saw a some posting in the Apple forum about this problem, but no solution yet :(Threw
Can you provide a link?Umpire
Still an issue with iOS 17.1 :-/Umpire
Same issue!!! did you find any solution?Geomancy
How is there no solution to this months and months later? Seems like a big bug?Loos
U
0

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://mcmap.net/q/1169269/-swiftui-ios16-toolbaritem-placement-keyboard-button-disappears-after-first-tap-use

Umpire answered 18/10, 2023 at 20:28 Comment(2)
It didn't work for me (Xcode 15.1)Geomancy
On real device it works for me, but on simulator its not working.Fearsome
M
0

It works on iOS 17+ devices and 16.0+ devices & simulators, but not on iOS 17 simulator. This is certainly a bug.

Megalomania answered 29/11, 2023 at 13:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.