如何在 iPhone 上按“完成”时禁用输入板?

发布于 2024-07-13 16:51:04 字数 53 浏览 4 评论 0原文

我想在按“完成”时禁用 iPhone 上的输入板。 关于如何检测按钮按下事件有什么想法吗?

I want to disable input pad on iphone when pressing 'done'. Any ideas about how to detect button press event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南七夏 2024-07-20 16:51:04

编程方法

要注册按钮按下事件,您可以采用编程方法:

[button addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside]

其中buttonPressed:是“self”类中的方法:

-(void)buttonPressed:(id)sender;

当然,您可以指定指向任何对象而不是“self”的指针,只要该对象有一个buttonPressed:方法。

Interface Builder

您还可以使用Interface Builder。 创建一个要执行的方法:

-(IBAction)buttonPressed:(id)sender;

然后右键单击界面生成器中的按钮。 您应该看到操作列表。 在“touch up”操作中,单击圆形按钮,然后将连接器拖动到表示放置 buttonPressed: 方法的类的对象。

禁用输入板

我不确定你的意思。 您是在谈论消除键盘输入吗? 如果是这样,您必须调用“resignFirstResponder:”方法。 例如,由于您正在编辑文本字段,因此键盘会弹出。 要关闭键盘,请在文本字段上调用以下方法:

[textField resignFirstResponder];

Programatic Method

To register button press events you can either do the programmatic approach:

[button addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside]

Where buttonPressed: is a method in the class "self":

-(void)buttonPressed:(id)sender;

You can specify a pointer to any object instead of "self" of course, as long as the object has a buttonPressed: method.

Interface Builder

You can also use Interface Builder. Create a method that you want to execute:

-(IBAction)buttonPressed:(id)sender;

Then right click on the button in interface builder. You should see a list of actions. On the "touch up" action click on the circle button, and drag a connector to the object representing the class where you put the buttonPressed: method.

Disabling Input Pad

I'm not sure what you mean by this. Are you talking about dismissing a keyboard input? If so, you have to call the "resignFirstResponder:" method. Say, for example, the keyboard pops up because you are editing a text field. To dismiss the keyboard call the following method on the text field:

[textField resignFirstResponder];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文