如何以编程方式设置特定UITextField的返回键? [英] How do I programmatically set the Return Key for a particular UITextField?

查看:78
本文介绍了如何以编程方式设置特定UITextField的返回键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能相信这个问题还没有被问过,但是我一直无法找到,所以这是我的假设。

I can't believe that this question hasn't been asked yet, but I have been unable to find it so that is my assumption.

我创建了custom UITableViewCel l子类使用Interface Builder。这些都包含 UILabel UITextField ,用于我们的登录屏幕。

I have created custom UITableViewCell subclasses using Interface Builder. These each contain a UILabel and a UITextField and are used for our login screen.

在第一个 UITextField ,我想键盘键说下一个。但是,在第二个 UITextField ,我想要说完成。

On the first UITextField, I want the Keyboard Key to say Next. However, on the second UITextField, I want it to say "Done."

如何以编程方式更改键盘上的返回键的值?我不能使用 Interface Builder ,因为这将使两个键显示为完成

How do I programmatically change the value of the Return Key on the keyboard? I cannot use Interface Builder, since that would make both keys appear as Done.

谢谢!

推荐答案

对于第一个 UITextField ,阅读 THIS 教程,了解如何创建按钮。您可以从那里学习逻辑,并使用下一步按钮,而不是完成按钮。

For the first UITextField, Read THIS tutorial on how to create a button on a Keyboard. You can learn the logic from there and use a Next button instead of Done button.

   //if you just want to make it appear NEXT//

    textField.returnKeyType = UIReturnKeyNext;

而对于第二个 UITextField ,请使用。 ..

And for the second UITextField, use...

   // for DONE //

    textField.returnKeyType = UIReturnKeyDone;

你一般可以创建和重命名按钮到任何东西,并确保你给出正确的 IBAction 。如果你创建自己的自定义按钮,看看上面的教程,了解如何将它放在正确的坐标和东西。

You can in general create and rename the button to anything, and make sure you give the right IBAction on the event that that button is pressed. In case you do create your own custom button, look at the tutorial above to learn about placing it in the right coordinates and stuff.

这篇关于如何以编程方式设置特定UITextField的返回键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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