当键盘抬起时在滚动视图中滚动(就像在 Notes 应用程序 iOS 中一样)
当键盘出现时,我可以取消隐藏我的文本字段,但现在的问题是,我希望用户能够在视图中滚动并看到文本字段上方的其他内容,即使键盘打开时也是如此。就像您可以在笔记应用程序中执行此操作一样,即使键盘弹起,您也可以在笔记中滚动。
谢谢!
I could unhide my text field when the keyboard comes up, but the problem now is that I want the user to be able scroll in the view and see other stuff which was above the text field even when the keyboard is up. Just like you can do it in the notes application, you can scroll in the notes even when the keyboard up.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有两种解决方案:
• 调整scrollView 框架的大小,使其高度适合您的键盘。
• 更改scrollView 的contentOffset。
You have two solutions :
• Resize the frame of your scrollView with a height that's perfectly to your keyboard.
• Change the contentOffset of your scrollView.
注册
UIKeyboardWillShowNotification
和UIKeyboardWillHideNotification
,获取键盘大小和动画速度并调整滚动视图的大小。Register for
UIKeyboardWillShowNotification
andUIKeyboardWillHideNotification
, get the keyboard size and animation speed and resize the scroll view.