Skip to content

Instantly share code, notes, and snippets.

@nathandud
Created January 14, 2026 04:47
Show Gist options
  • Select an option

  • Save nathandud/edf9f9158f813495648868136e6021c6 to your computer and use it in GitHub Desktop.

Select an option

Save nathandud/edf9f9158f813495648868136e6021c6 to your computer and use it in GitHub Desktop.
Unpredictable number pad behavior on iPad with Xcode 26
// If built with Xcode 16, the text fields present the full keyboard with
// numbers on the top row. This has been the default iPadOS behavior for as long
// as I can remember.
// If built with Xcode 26, a number pad popover is shown initially but if the
// text field is tapped again or the cursor is moved, the full keyboard shows
// instead. On subsequent taps into a text field, it's a toss-up whether you get
// the popover or the full keyboard.
import SwiftUI
@main
struct NumberPadTestApp: App {
var body: some Scene {
WindowGroup {
NumberPadDemoView()
}
}
}
struct NumberPadDemoView: View {
@State private var text: String = ""
var body: some View {
VStack(spacing: 40) {
// Title
Text("iPadOS Number Pads")
.font(.largeTitle)
.padding(.top, 100)
// SwiftUI
VStack(alignment: .leading, spacing: 10) {
Text("SwiftUI TextField (.numberPad)")
.font(.system(size: 32))
.foregroundColor(.blue)
TextField("", text: $text)
.keyboardType(.numberPad)
.font(.system(size: 32))
.textFieldStyle(RoundedBorderTextFieldStyle())
}
// UIKit
VStack(alignment: .leading, spacing: 10) {
Text("UIKit UITextField (.numberPad)")
.font(.system(size: 32))
.foregroundColor(.green)
SimpleUIKitTextField()
.frame(height: 36)
}
Spacer()
}
.padding()
.background(Color(UIColor.systemGroupedBackground))
}
}
// MARK: - UIKit Text Field Representable
struct SimpleUIKitTextField: UIViewRepresentable {
func makeUIView(context: Context) -> UITextField {
let textField = UITextField()
textField.keyboardType = .numberPad
textField.borderStyle = .roundedRect
textField.font = .systemFont(ofSize: 32)
return textField
}
func updateUIView(_ uiView: UITextField, context: Context) { }
}
@iOkay

iOkay commented May 8, 2026

Copy link
Copy Markdown

Encountered the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment