IOS 8 - the keyboard changes color if you press the "Home" button on the iPad and return to

Repeat:

  • Create an empty project with one view
  • Drag TextField onto the canvas
  • Set the TextFieldAppearance keyboard to Dark
  • Launch the application on the iPad (device or simulator).
  • Tap TextField to open the keyboard (it's dark)
  • Click "Home", then return to the application.
  • Note that the keyboard changes color (to white).

Presumably, the color of the keyboard changes according to the background. However, in this case, some of the keys remain dark, so this seems like an error in iOS (see the attached screenshot).

Does anyone want to shed light on this? We are using a workaround that includes hiding the keyboard and redisplaying, but this is not ideal.

enter image description here

+6
source share
1 answer

This code can close the keyboard when the "Home" button is pressed, and return it when the application is restarted. You need to configure the UITextFields delegate to a controller of the form:

class ViewController: UIViewController, UITextFieldDelegate { private var _textField: UITextField! private var _isFirstResponder: Bool! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. NSNotificationCenter.defaultCenter().addObserver(self, selector: "didBecomeActiveNotification:", name: UIApplicationDidBecomeActiveNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "willResignActiveNotification:", name: UIApplicationWillResignActiveNotification, object: nil) } deinit { NSNotificationCenter.defaultCenter().removeObserver(self) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func didBecomeActiveNotification(nofication: NSNotification) { if _isFirstResponder? == true { _textField?.becomeFirstResponder() } } func willResignActiveNotification(nofication: NSNotification) { if _textField?.isFirstResponder() == true { _isFirstResponder = true _textField?.resignFirstResponder() } else { _isFirstResponder = false } } func textFieldShouldBeginEditing(textField: UITextField) -> Bool { _textField = textField return true } } 
0
source

Source: https://habr.com/ru/post/981757/


All Articles