iPhone:键盘屏幕 [英] iPhone: keyboard blocks screen

查看:86
本文介绍了iPhone:键盘屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

UITableView和键盘滚动问题

我有一个屏幕上有几个文本字段( UITextField ),用于从用户收集信息,最终占用大部分屏幕。当用户选择一个字段时,软键盘会出现(如预期的那样),但它会掩盖屏幕下方显示的字段。为了进入这些字段,用户必须关闭键盘并选择它们,这样,字段再次被掩盖,用户无法看到他们正在键入的内容。

I've got a screen which has several text fields (UITextField) for gathering information from the user which ends up taking up most of the screen. when the user selects a field the soft keyboard appears (as expected) but it covers up the fields that appear further down on the screen. In order to get to those fields the user has to close the keyboard and select them, and upon doing so, the field is covered up again and the user can't see what they're typing.

我尝试将文本字段包装在 UIScrollView 中,希望当键盘占用屏幕空间时我可以滚动uppper部分屏幕截取到其他文本字段,但这不起作用。

I tried wrapping the text fields in a UIScrollView, hoping that when the keyboard took up space on the screen i would be able to scroll the uppper portion of the screen down to the other text fields, but this did not work.

我希望得到这种滚动行为。有谁知道怎么做?

I'm hoping to get this scrolling behavior. Does anyone know how to do it?

-TIA

推荐答案

对于类似的问题和一些示例代码有一个很好的答案这里

There's a good answer to a similar question and some sample code here.

基本上,您注册接收 UIKeyboardWillShowNotification UIKeyboardWillHideNotification ,然后您手动滚动视图以进行补偿。

Basically, you register to receive the UIKeyboardWillShowNotification and the UIKeyboardWillHideNotification, then you manually scroll the view to compensate.

这篇关于iPhone:键盘屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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