用户登录
用户注册

分享至

iPhone - 键盘隐藏文本字段

  • 作者: qzuser11389002
  • 来源: 51数据库
  • 2023-02-09

问题描述

我正在使用 UITextField 接收用户输入.但是,由于我的文本字段朝向笔尖的中间/底部,因此当键盘弹出时它会被隐藏.有什么方法可以将它与键盘一起滑动,以便在选择过程中它位于键盘的顶部?另外,由于我也在使用数字键盘,有没有一种简单的方法可以在某处包含完成按钮?

I am using UITextField to receive user inputs. However, since my textfields are towards the middle/bottom of the nib, it gets hidden when the keyboard pops up. Is there any way sort of slide it along with the keyboard so that it's on the top of the keyboard during selection? Also, since I am also using the numberpad, is there an easy way to include a done button somewhere?

感谢您的帮助.

推荐答案

键盘出现时滚动,我喜欢本教程来自 Cocoa With Love.

To scroll when the keyboard appears, I like this tutorial from Cocoa With Love.

要关闭数字键盘,您可以 在键盘上放置一个自定义的完成"按钮或在屏幕的其余部分制作一个不可见的按钮.我已经用代码完成了后者,但是 本教程 使用界面生成器.

To dismiss the number keypad, you can put a custom "Done" button on the keypad or make an invisible button over the rest of the screen. I have done the latter with code, but this tutorial uses Interface Builder.

软件
前端设计
程序设计
Java相关