Skip to content

Instantly share code, notes, and snippets.

@c16a
Last active March 7, 2017 10:22
Show Gist options
  • Save c16a/c64e2c91a4d9d84b5c03dab4afc47ce4 to your computer and use it in GitHub Desktop.
Save c16a/c64e2c91a4d9d84b5c03dab4afc47ce4 to your computer and use it in GitHub Desktop.
Swift workaround to solve delay in assigning first UITextField responder in UIKit and erroneous responders
// Add this function to the end of AppDelegate.swift
// Call this function in
// func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
func applyFirstResponder() {
let dummyField = UITextField()
self.window?.addSubView(dummyField)
dummyField.becomeFirstResponder()
dummyField.resignFirstResponder()
dummyField.removeFromSuperview()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment