1.控制输入的长度(此方法同时可以控制复制粘贴)
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *string0 = [textField.text stringByReplacingCharactersInRange:range withString:string];
NSLog(@"%@",string0);
if (string0.length>15) {
textField.text=[string0 substringToIndex:15];
[[ZCYAlertView defaultAlert] promptMessage:@"名字已经很长了哦!" atDuration:2];
return NO;
}
else
return YES;
}