ios中键盘遮挡了输入框,在storyboard中怎么解决。

在stroryboard中设计登录界面,账号和密码的输入框,一点击输入键盘就遮挡住了。这个问题怎么解决?知道的请告诉我一下,谢谢了。

需要添加代码来解决,判断是否弹出了键盘,然后整体移动View视图的位置,直接在stroryboard应该是不能修改

因为你的输入框太低,只能监听键盘解决,或者用个iqkeyboardmanager

使用scrollview,在上面布局UI
添加键盘显示的消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardwillShown:) name:UIKeyboardWillShowNotification object:nil];

  • (void)keyboardwillShown:(NSNotification *)notif{ NSDictionary *info = [notif userInfo]; NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey]; CGSize keyboardSize = [value CGRectValue].size; CGRect rect = [[UIScreen mainScreen]bounds]; NSInteger heigth = rect.size.height; NSInteger maxY = CGRectGetMaxY(self.view.frame); if (heigth - maxY < keyboardSize.height) { rect = self.view.frame; rect.origin.y -= keyboardSize.height - heigth + maxY; self.view.frame = rect; } } 然后计算键盘高度,检查是否挡住了自己的输入框,挡住了就上拉scrollview,键盘消失的时候恢复scrollview

storyboard上可以使用第三方库,直接布局就好。

使用第三方 TPKeyboardAvoiding 可以解决,

各位还没解决的,可以去我博客看看,不用第三方库就能解决输入框被挡住的问题:[url=http://blog.csdn.net/winer888/article/details/51084756]http://blog.csdn.net/winer888/article/details/51084756[/url]

各位还没解决的,可以去我博客看看,不用第三方库就能解决输入框被挡住的问题:http://blog.csdn.net/winer888/article/details/51084756