以编程方式点击UITextField [英] Programmatically Tap a UITextField

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

问题描述

我有一个名为mainTextField的 UITextField 和一个直接位于其下的 UIButton ,称为textButton.理想情况下,当用户按下textButton时,mainTextField应该认为用户已经在其上轻按了手指,从而导致键盘弹出并像通常那样开始编辑.我已经阅读了文档,但不知道发送哪条消息来完成此任务,有人有任何想法吗?

I have a UITextField named mainTextField, and a UIButton placed directly under it, called textButton. Ideally, when the user presses textButton, then mainTextField should think that a user has tapped their finger on it, causing a keyboard to pop up and editing to begin like it normally would. I've read through the docs and I have no idea which message send to use to accomplish this, does anyone have any ideas?

这是一个个人应用程序,我不打算将其提交到App Store,因此可以进行时髦的推理.谢谢您的关心!

This is a personal app, I do not plan on submitting it to the App Store, so the funky reasoning is okay to do. Thank you for the concern though!

推荐答案

只需调用 [mainTextField成为FirstResponder] .

[mainTextField resignFirstResponder] 相反.

这篇关于以编程方式点击UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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