- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
{
if ([string isEqualToString:@"\n"])
{
return YES;
}
NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
if (creatNewpwdTextFied == textField)
{
if ([toBeString length] > 16) {
textField.text = [toBeString substringToIndex:16];
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请输入6至16位密码" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] ;
[alert1 show];
return NO;
}
}
return YES;
}
本文介绍了一个iOS应用中关于密码输入的实现方式,通过UITextField代理方法控制密码长度,并展示如何使用UIAlertView进行错误提示。
1616

被折叠的 条评论
为什么被折叠?



