ios - TextField and Warning -


i have uitextfield object , take input textfield. if length of input shorter 2, want give warning sign in textfield bar.

is impossible ?

if so, how can handle ?

edit:

i handled it. put label in textfield , run auto layout. then, chose delegate of textfield , make inputviewcontroller conform uitextfielddelegate protocol. finally, use func textfield(_ textfield: uitextfield, shouldchangecharactersin range: nsrange, replacementstring string: string) -> bool

implement uitextfielddelegate in view controller , use textfielddidendediting check text length.

func textfielddidendediting(_ textfield: uitextfield) {     if let textfieldtext = textfield.text {        print("textfieldtext length - \(textfieldtext.count)")        if (textfieldtext.count < 2) {           showwarning(message: "your message here")        }     } }  func showwarning(message: string?){    // show warning message using uialertcontroller here. } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -