2

Strange behaviour observed on UITextField text disappears,

Steps: Type text in UITextField and click home button. Open another application (App) and click home button. Then Open First App the UITextField in text is disappears. Issue observed in IPhone 6s version 9.2.1. but perfectly working in simulator.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kiran
  • 4,285
  • 7
  • 53
  • 98
  • do you store typed text any where? that allocated to the textfiled? – Nitin Gohel Mar 11 '16 at 05:52
  • Not able to reproduce in my case, Check if there is any code in viewwillappear which is making textbox empty or applicationdidenterforeground. – Awesome.Apple Mar 11 '16 at 05:54
  • see this once http://stackoverflow.com/questions/19352663/uitextfield-text-disappears-on-every-other-keystroke – Anbu.Karthik Mar 11 '16 at 05:56
  • Not able to reproduce either. Maybe you can create a breakpoint and run your app in debug mode to retry. – xi.lin Mar 11 '16 at 06:12
  • http://stackoverflow.com/questions/22494543/disappearing-uitextfield-text Same issue which i am refering ! – kiran Mar 11 '16 at 07:07
  • Possible duplicate of [Disappearing UITextField text](http://stackoverflow.com/questions/22494543/disappearing-uitextfield-text) – Machavity Apr 26 '17 at 23:59

1 Answers1

0

You can override this method in your custom responders to update your object's state or perform some action such as highlighting the selection. If you override this method, you must call super at some point in your implementation.

The custom Class should be similar to:

class CustomSecureTextField: UITextField { 
    override func becomeFirstResponder() -> Bool {
        super.becomeFirstResponder()
         //if !isSecureTextEntry {
         //  return true 
         //} 
         if let currentText = text {  
             insertText(currentText)
         } 
         return true
    } 
}
Sakir Sherasiya
  • 1,562
  • 1
  • 17
  • 31