发现 iPad 上键盘隐藏的内容
我有一个包含多个 UITextView 的视图,用户需要点击这些视图才能开始编辑。然而,在这个UIView
的横向视图中,键盘覆盖了这些字段的一半以上。确保用户仍然可以访问键盘下的内容同时保持简单性的推荐方法是什么?
I have a view with multiple UITextView
s which need to be tappable to the user to begin editing. However, in the landscape view of this UIView
, the keyboard covers up more than half of these fields. What's the reccomended way to make sure that the user can still access the content under the keyboard while maintaining simplicity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 textField Delegate 方法来解决您的问题。
例如,当用户点击文本字段开始编辑时,将调用委托方法
- (void)textFieldDidBeginEditing:(UITextField *)textField
在此方法中更改主视图的框架并将其向上推一点。例如,在纵向方向的 iPad 中,主视图的框架将为 (0,0,768,1024),现在在该委托方法中将框架更改为 (0,-50, 768,1024)。当用户完成编辑并再次执行其他操作时,使用其他委托方法(如- (void)textFieldDidEndEditing:(UITextField *)textField.
更理想的情况是将所有对象放在一个子视图中并更改该子视图的框架,而不是更改主视图的框架。
我希望这有帮助。
You can use the textField Delegate methods to solve your problem.
For example when the user taps the textField to begin editing, a delegate method will be called
- (void)textFieldDidBeginEditing:(UITextField *)textField
in this method change your main view's frame and push it a bit up. For example in iPad in Portrait orientation the frame of your main view would be (0,0,768,1024) now in that delegate method change the frame to (0,-50, 768,1024). And when the user is done editing and performs some other action again reset the frame of the view to its original (0,0,768,1024) using other delegate methods like- (void)textFieldDidEndEditing:(UITextField *)textField
.The more ideal thing would be to put all your objects in one subview and change the frame of that subview rather than changing the frame of the main view.
I hope this helps.