ios - After Counting data how can i move to next textField. Where to put code to resign first responder? -


func textfield(textfield: uitextfield, shouldchangecharactersinrange range: nsrange, replacementstring string: string) -> bool {      let currentcharactercount = textfield.text?.characters.count ?? 0     if (range.length + range.location > currentcharactercount){         return false     }     let newlength = currentcharactercount + string.characters.count - range.length    return newlength <= 1   } 

where should resign firsttextfield ? need move 1 text field textfield user enter 1 character only

assign tags textfields in sequence want them active 1 after other. next textfield based on current textfield tag , make first responder. here code this.

func textfield(textfield: uitextfield, shouldchangecharactersinrange range: nsrange, replacementstring string: string) -> bool {      let currentcharactercount = textfield.text?.characters.count ?? 0     if (range.length + range.location > currentcharactercount){         return false     }     let newlength = currentcharactercount + string.characters.count - range.length     if(newlength < 1){         return true     }else if (newlength == 1){          let textfield = self.view.viewwithtag(textfield.tag + 1)          let delayinseconds = 0.5         let delay = dispatch_time(dispatch_time_now, int64(delayinseconds * double(nsec_per_sec)))         dispatch_after(delay, dispatch_get_main_queue()) {             textfield?.becomefirstresponder();         }         return true;      }else{         return false;     } } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -