// 实现UITextfield的代理方法
- (void)textViewDidChange:(UITextView *)textView
{
NSInteger number = [textView.text length];
if (number > 10)
{
UIAlertView *tipAlert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"字符个数不能大于10" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[tipAlert show];
textView.text = [textView.text substringToIndex:10];
number = 10;
}
}
限制UITextFeild字数
最新推荐文章于 2021-11-11 11:11:28 发布