我正在寻找 UITextField 的方法,它在我输入 UITextField 后产生效果。
我有一个方法来进行计算我使用一个按钮,但我不想使用,我希望你在我在 UITextField 中输入数字后运行这个方法。
使用哪种方法有什么技巧吗?
感谢您的帮助。
最佳答案
- 实现
UITextFieldFieldDelegate
协议(protocol) - 将您的文本字段委托(delegate)给您的 View Controller
self.textField.delegate = self;
然后实现shouldChangeCharactersInRange
方法
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];
[self doCalculations];
return NO;
}
关于ios - 方法 UItextfield - 在我输入 UITextField 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19760793/