键盘的方式textfields如何向上移动视图 [英] Keyboard in the way of textfields how to move view up
问题描述
我使用Xcode的SplitView模板。
我在视图的细节一侧放置了一堆文本字段,但我忘了键盘占用
当键盘进入屏幕时如何向上移动这个细节视图? >解决方案
我使用这个解决方案从总是有用的当我不能使用UIScrollView时,可爱与可爱。
如果你想添加一个UIScrollView你的层次结构,只需在文本字段上方的层次结构中插入UIScrollview,并在用户点击文本项开始编辑时使用此代码:
UIScrollView * v =(UIScrollView *)self.view;
CGRect rc = [textField bounds];
rc = [textField convertRect:rc toView:v];
rc.origin.x = 0;
rc.origin.y - = 60;
rc.size.height = 400;
[self.scroll scrollRectToVisible:rc animated:YES];
祝你好运!
I am using Xcode's SplitView template.
I have placed a bunch of text fields on the 'detail' side of the view however I forgot about the keyboard taking up half the screen.
How do I move this detail view up when the keyboard comes onto the screen?
I used this solution from the always-useful Cocoa With Love when I could not use a UIScrollView.
If you want to add a UIScrollView you your hierarchy, it gets even easier. Just insert the UIScrollview in the hierarchy above the text fields and use this code when the user taps the text item to begin editing:
UIScrollView* v = (UIScrollView*) self.view ;
CGRect rc = [textField bounds];
rc = [textField convertRect:rc toView:v];
rc.origin.x = 0 ;
rc.origin.y -= 60 ;
rc.size.height = 400;
[self.scroll scrollRectToVisible:rc animated:YES];
Good Luck!
这篇关于键盘的方式textfields如何向上移动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!