ios – SwiftUI TextField has a couple of seconds delay on first tap when testing with real iPhone


Xcode version: 15.2 (15C500b)

iOS version: 17.2.1 (although in the last two updates before this one as well)

My device: iPhone 12

Easy to reproduce for me:

  1. Create a new iPhone App project using Xcode
  2. Write some code like this:
import SwiftUI

struct ContentView: View {
    @State var text: String = "";

    var body: some View {
        VStack {
            Text("Hello, world!")

            TextField("Tap me", text: $text)
                .padding()
                .background(Color(.systemGray6))
                .cornerRadius(10)
                .padding(.horizontal, 20)
                .keyboardType(.numberPad)
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

  1. Run this on your real iPhone and tap on the TextField

I am getting a 1 to 2 second delay before focus, the cursor and the appearance of the keypad indicate that I can now type something. I also get this error on Xcode’s console: <0x101e0bac0> Gesture: System gesture gate timed out.

I tried it with 2 textfields and once you experience the delay on the first tap, you can then switch between them instantly. Curiously, this doesn’t seem to happen on the simulator at all.

Anyone know what this is about and how to fix it?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img