ios - Responding to DELETE on UIKeyboardTypeDecimalPad -


this thing driving me crazy. how repond user pressing delete key on numeric keypad? can't find delegate method , see empty string when shouldchangecharactersinrange() called.

thanks!

i figured out...

- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range                                                 replacementstring:(nsstring *)string {      if ([string length] == 0)         return yes;      nscharacterset *nonnumberset = [[nscharacterset decimaldigitcharacterset] invertedset];     string = [[string componentsseparatedbycharactersinset:nonnumberset] componentsjoinedbystring:@""];     textfield.text = [textfield.text stringbyreplacingcharactersinrange:range withstring:string];   return no; 

}


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -