1.给相应的输入框对象添加监听事件 :
[self.passwordTFaddTarget:selfaction:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]
2.实现监听触发方法
-(void)textFieldDidChange:(UITextField *)textField
{
if(textField==self.passwordTF)
{
if(textField.text.length > 6)
{
textField.text = [textField.text substringToIndex:6];
}
}
}