UITextField *nameTxetField=[[UITextField alloc] initWithFrame:CGRectMake(50, 100, 200, 30)];
[nameTxetField addTarget:self action:@selector(limitTextlength:) forControlEvents:UIControlEventEditingChanged];
-(void)limitTextlength:(UITextField *)textField{
if ([textField.text length]>16) {
textField.text=[textField.text substringToIndex:16];
}
}
[nameTxetField addTarget:self action:@selector(limitTextlength:) forControlEvents:UIControlEventEditingChanged];
-(void)limitTextlength:(UITextField *)textField{
if ([textField.text length]>16) {
textField.text=[textField.text substringToIndex:16];
}
}