ipad - How to accept numbers in input field only in iphone app -
i making app want when user inputs data whatever user enter if enters not take input , show nothing in textfield , if enter number should accept.
following code should you, not allow other text entered in text field other numbers.
- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { static nscharacterset *charset = nil; if(!charset) { charset = [[[nscharacterset charactersetwithcharactersinstring:@"0123456789"] invertedset] retain]; } nsrange strlocation = [string rangeofcharacterfromset:charset]; return (strlocation.location == nsnotfound); }
Comments
Post a Comment