ios - 方法 UItextfield - 在我输入 UITextField 之后

标签 ios objective-c uitextfield

我正在寻找 UITextField 的方法,它在我输入 UITextField 后产生效果。

我有一个方法来进行计算我使用一个按钮,但我不想使用,我希望你在我在 UITextField 中输入数字后运行这个方法。

使用哪种方法有什么技巧吗?

感谢您的帮助。

最佳答案

  1. 实现 UITextFieldFieldDelegate 协议(protocol)
  2. 将您的文本字段委托(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/

相关文章:

ios - UIView 与 CAShapeLayer 的用法(绘图、动画、用户交互)

ios - 什么是 start_wqthread?它会影响 UIMainThread 吗?

ios - 加减法uitextfield

ios - 快速文本字段的自定义边框

ios - UIScrollView subview 中的 UILabels 上的 UITapGestureRecognizer 不起作用

ios - 制作具有静态和属性前缀的 UITextField

ios - 如何找到包标识符的所有者

ios - AudioKit.output setter 因 SIGABRT 而崩溃

ios - 单击运行时创建的按钮会使我的 ios 应用程序崩溃 (swift)

objective-c - 带有 NULL 指针的 CGRectDivide