UiTextField events

后端 未结 3 713
后悔当初
后悔当初 2020-12-20 12:45

When I create UITextField inside Interface Builder, I can access Events tab for it, which has events like Value changed, Touch cancel, Touch drag, etc. I can assign my own m

相关标签:
3条回答
  • 2020-12-20 13:19

    Instead of UIControlEventValueChanged, you should use UIControlEventEditingChanged:

    [_titleTextField addTarget:self action:@selector(handleTitleValueChanged:) forControlEvents:UIControlEventEditingChanged];
    
    0 讨论(0)
  • 2020-12-20 13:24

    Refer to Apple documentation for UIControl. After initializing your textField, call addTarget:action:forControlEvents:

    example for the touch event ending an edit session

    [textField addTarget:self action:@selector(handleTouchValueChanged:) forControlEvents: UIControlEventEditingDidEnd]
    
    0 讨论(0)
  • 2020-12-20 13:34

    UIControlEventEditingChanged fires whenever user changes value [synchronous with typing or keyup] which could cause extra hits to your data handler routine, if you're saving values based on that event, expecting it to be some kind of final value from user input...

    0 讨论(0)
提交回复
热议问题