iOS开发 iOS12 - 使用WKWebView出现input键盘失去焦点页面不回弹的问题

发现在iOS12上出现键盘失去焦点,页面不回弹的问题。
解决方案:

监听键盘的谈起和隐藏

/// 监听将要弹起

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardShow) name:UIKeyboardWillShowNotification object:nil];

/// 监听将要隐藏

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardHidden) name:UIKeyboardWillHideNotification object:nil];

监听方法中设置WKWebView的scrollview的contentOffset

/** 键盘谈起屏幕偏移量 */

@property (nonatomic, assign) CGPoint keyBoardPoint;

#pragma mark - addObserverKeyboard

/// 键盘将要弹起

- (void)keyBoardShow {

    CGPoint point = self.webView.scrollView.contentOffset;

    self.keyBoardPoint = point;

}

/// 键盘将要隐藏

- (void)keyBoardHidden {

    self.webView.scrollView.contentOffset = self.keyBoardPoint;

}



原文:https://blog.csdn.net/weixin_33827590/article/details/91367470?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control

你可能感兴趣的:(iOS开发 iOS12 - 使用WKWebView出现input键盘失去焦点页面不回弹的问题)