我正在处理一个在webview中运行的表单。在一个本机ios弹出窗口出现并关闭后,例如,当键盘出现在文本区域或下拉弹出窗口时,就会出现点击问题。点击时有一个偏移量,该偏移量大约等于键盘/下拉弹出菜单的高度。因此,当我点击表单上的一个点时,会按下200-300像素下的另一个组件。它只出现在ios12中。我为此找到的唯一解决办法是收缩和收缩。你对解决方案有什么建议吗?
发布于 2018-10-11 15:27:31
我用了一个棘手的方法来修复它,你应该试试:
- (void)keybordDidHide {
if (!CGPointEqualToPoint(self.lastContentOffset, self.webView.scrollView.contentOffset)) {
[self.webView.scrollView setContentOffset:self.lastContentOffset];
[self.webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
}
- (void)keybordWillShow {
self.lastContentOffset = self.webView.scrollView.contentOffset;
}发布于 2019-01-17 11:46:23
这对我来说很管用。
ViewController.h
@property (nonatomic) CGPoint lastContentOffset;ViewController.m
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
- (void)onKeyboardWillShow:(NSNotification *)notification {
self.lastContentOffset = self.webView.scrollView.contentOffset;
}
- (void)onKeyboardWillHide:(NSNotification *)notification {
if (!CGPointEqualToPoint(self.lastContentOffset, self.webView.scrollView.contentOffset)) {
[self.webView.scrollView setContentOffset:self.lastContentOffset];
[self.webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
if (!CGPointEqualToPoint(self.lastContentOffset, self.webView.scrollView.contentOffset)) {
[self.webView.scrollView setContentOffset:self.lastContentOffset];
[self.webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
}https://stackoverflow.com/questions/52688183
复制相似问题