UiTextField事件 [英] UiTextField events

查看:116
本文介绍了UiTextField事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Interface Builder中创建UITextField时,我可以访问事件选项卡,它具有值更改,触摸取消,触摸拖动等事件。我可以为每个事件分配自己的方法。当我用编程方式使用alloc创建UITextField时,我该怎么做?

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 methods to every of those events. How can I do the same, when I create UITextField programmatically with alloc?

推荐答案

请参阅Apple文档中的 UIControl 。初始化 textField 后,调用 addTarget:action:forControlEvents:

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]

这篇关于UiTextField事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆