我怎样才能检测的UITextField按键事件? [英] How can I detect a KeyPress event in UITextField?

查看:153
本文介绍了我怎样才能检测的UITextField按键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的UITextView 有一个更改事件来处理按键。然而,的UITextField 还没有这样的事件。

In UITextView there is a Changed event to handle keypress. However the UITextField has not such event.

我怎样才能检测的UITextField

有一个方法,这里介绍 使用通知,但我有问题是,我不能从TextFieldTextDidChangeNotification退订。

There is a method described here using notifications, however the problem I have is that I cannot unsubscribe from the TextFieldTextDidChangeNotification.

推荐答案

我不知道这是你的问题。你好像是第一个回答自己,即
解决方案(从你的链接)是使用 NSNotificationCenter.DefaultCenter.AddObserver

I'm not sure which is your question. The first one you seem to have answered yourself, i.e. the solution (from your link) is to use NSNotificationCenter.DefaultCenter.AddObserver.

二是有关的退订的 - 如果你想停下来观察你应该调用以前的方法对应,即 NSNotificationCenter.DefaultCenter.RemoveObserver

The second is about unsubscribing - if you want to stop observing you should call the previous method counterpart, i.e. NSNotificationCenter.DefaultCenter.RemoveObserver.

只要保持对象从的addObserver 返回,所以你可以把它提供给 RemoveObserver

Just keep the object returned from AddObserver so you can supply it to RemoveObserver.

注意::如果我没有正确理解你的问题,请使用修改并添加你想要什么的一些细节和/或代码来实现,我们会尽我们最大的努力帮助: - )

note: If I did not understand your question correctly please use edit and add some details and/or code of what you want to achieve and we'll do our best to help :-)

这篇关于我怎样才能检测的UITextField按键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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