数字键盘关闭?

发布于 2024-09-03 14:05:18 字数 193 浏览 5 评论 0原文

大家好,

我有 2 个 textField 和 1 个 textview。

在 2 个文本字段中,有一个文本字段需要填写数字。 为此,我提供了数字键盘。 我无法关闭数字键盘,因为我无法选择任何选项来点击数字键盘关闭。

是否可以关闭数字键盘 ??

如果是的话,任何人都可以指导我。

问候 希希尔

HI all,

I am having a 2 textFeild and 1 textview.

out of 2 textfeild,one textfield requires number to be filled in there.
so for that i hv provided numeric keyboard.
i m not able to dismiss numeric keyboard,since i cant c any option to hit the numeric keyboard dismiss.

is it possible to dismiss numeric keyboard
??

if yes than can anyone guide me through.

regards
shishir

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

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

发布评论

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

评论(3

萌辣 2024-09-10 14:05:18

您有 2 个选择:在数字键盘中添加返回键盘或捕获用户选择另一个文本字段并关闭那里的数字键盘的事件。以下是将返回(完成)按钮添加到数字键盘的链接。 用小键盘完成

You have 2 options: add a return keyboard in a numpad keyboard or catch the event of user select another textfield and dismiss the numpad there. Here is the link to add a return (done) button to a numpad keyboard. Done in numpad keyboard

不必了 2024-09-10 14:05:18

没有用于关闭数字键盘的按钮(尽管在 iPad 上您可以执行此操作)。如果您想自己执行此操作,则必须在代码中调用 [textfield resignFirstResponder]

There is no button to dismiss the numeric keypad (although on the iPad you can do this). You will have to call [textfield resignFirstResponder] in code if you want to do this yourself.

就此别过 2024-09-10 14:05:18

还有另一种可能的方法。对于那些正在寻找完美东西的人来说,vodkhang 的答案非常好。但如果您正在寻找一些解决方法,那么 textField.inputAccessoryView 可能会很有用。这个想法是在 inputAccessoryView 中显示完成按钮。以下是示例代码,

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 25)];
view.backgroundColor = [UIColor grayColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Done" forState:UIControlStateNormal];
button.frame = CGRectMake(320-60, 0, 60, 25);
[view addSubview:button];
textField.inputAccessoryView = view;

有几件事需要注意。

  • accessoryView 的宽度等于屏幕宽度。因此,您需要编写一些代码来根据您的应用程序管理外观。
  • 您可以为圆顶按钮赋予任何外观。而且在这里你不必担心苹果在键盘方面的设计变化。

There is one other possible way. For those who are looking for something perfect then vodkhang's answer is very good. But if you are looking for some work-around then textField.inputAccessoryView can be useful. The idea is to show done button in inputAccessoryView. Following is sample code

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 25)];
view.backgroundColor = [UIColor grayColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Done" forState:UIControlStateNormal];
button.frame = CGRectMake(320-60, 0, 60, 25);
[view addSubview:button];
textField.inputAccessoryView = view;

There are few things to be noted.

  • Width of accessoryView is equal to screen width. So you need to write some code for managing look and feel according to your application.
  • You can give any kind of look to you dome button. And here you don't have to worry about Apple's design changes in keyboard.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文