(IOS)scrollView上的输入框,键盘挡住的问题

推荐用IQKeyboardManager这个框架!

手动解决如下

1、监听键盘弹出/消失的通知

2、在通知中加入代码:

NSDictionary* info = [aNotification userInfo];

CGRectkeyPadFrame=[[UIApplication sharedApplication].keyWindow convertRect:[[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:self.view];

CGSize kbSize =keyPadFrame.size;

CGRectactiveRect=[self.view convertRect:activeField.frame fromView:activeField.superview];

CGRectaRect =self.view.bounds;

aRect.size.height -= (kbSize.height);

CGPointorigin =  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)scrollView上的输入框,键盘挡住的问题)