iOS scrollView上的输入框,键盘挡住的问题

释放双眼,带上耳机,听听看~!
推荐用IQKeyboardManager这个框架!
手动解决如下
1、监听键盘弹出/消失的通知
2、在通知中加入代码:
NSDictionary* info = [aNotification userInfo];
CGRect keyPadFrame=[[UIApplication sharedApplication].keyWindow convertRect:[[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:self.view];
CGSize kbSize =keyPadFrame.size;
CGRect activeRect=[self.view convertRect:activeField.frame fromView:activeField.superview];
CGRect aRect = self.view.bounds;
aRect.size.height -= (kbSize.height);

CGPoint origin =  activeRect.origin;
origin.y -= backScrollView.contentOffset.y;
if (!CGRectContainsPoint(aRect, origin)) {
    CGPoint scrollPoint = CGPointMake(0.0,CGRectGetMaxY(activeRect)-(aRect.size.height));
    [backScrollView setContentOffset:scrollPoint animated:YES];
}

 

人已赞赏
iOS文章

iOS开发 调用震动 (震动一下)

2020-2-10 23:17:07

iOS文章

iOS 判断字符串是否为空

2020-2-11 4:45:02

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索