只能输入非零开头的正整数用下面的代码

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string];
if ([result length] == 0) return YES; // Allow delete all character which are entered.

NSString *regex = @"^[0-9]*[1-9][0-9]*$";
NSPredicate *prd = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
return [prd evaluateWithObject:result];
}