/** 键盘谈起屏幕偏移量 */
@property (nonatomic, assign) CGPoint keyBoardPoint;
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification * _Nonnull note) {
// [ws.webView layoutSubviews];//TODO:
CGPoint point = ws.webView.scrollView.contentOffset;
ws.keyBoardPoint= point;
}];
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification * _Nonnull note) {
// [ws.webView layoutSubviews];//TODO:
ws.webView.scrollView.contentOffset = ws.keyBoardPoint;
ws.webView.bounds = ws.view.bounds;
ws.webView.scrollView.contentOffset = CGPointMake(0, 0);
}];
这里使用layoutSubviews 或者 重设contentOffset都可以解决这个问题
网友评论