iphone:uitextfield,具有同一委托的多个文本字段?
我的应用程序中有两个不同的文本字段,我将它们的 .delegate 属性设置为:self。 现在我实现了 uitextfielddelegate 协议的不同方法,但我希望能够单独控制两个文本字段。例如,我希望第一个文本字段在编辑开始时执行与第二个文本字段不同的操作...是此问题的唯一解决方案来设置分配不同的委托,还是有办法在两个文本字段都具有的情况下执行此操作分配给他们的同一个代表? 我希望我的问题是可以理解的,我尝试用最好的方式解释...... 提前致谢!
there are two different textfields in my applications and i set the .delegate property of both of them to: self.
Now i implemented different methods from the uitextfielddelegate protocol but i want to be able to control the two textfields individually. For instance i want the first text field to do something different when editing begins than the second textfield... Is the only solution to this problem to set the assign a different delegate or is there a way to do this with both of the textfield having the same delegate assigned to them?
I hope my question is understandable i tried it to explain the best way that i could.....
thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
初始化时在文本字段上设置
tag
,然后检查传递到委托方法的tag
中的UITextField
对象,然后您就可以区分两个文本字段:Set a
tag
on the textfield on initialization, then check theUITextField
object that is passed into the delegate method'stag
, then you'll be able to make a differentiation between the two textfields:有插入文本视图的两个引用,您可以在委托方法中比较它们。不需要太多标签
have two references of the inserted text views and u can compare them at the delegate methods. Not much needed with tags