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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -