Disable Scroll on a UIWebView allowed?

后端 未结 18 1481
深忆病人
深忆病人 2020-12-07 11:52

I have to show a web article with a UITableView under the article.

The only option I found was to display the article in a UIWebView in the

18条回答
  •  旧巷少年郎
    2020-12-07 12:25

    I needed to disable scrolling because dismissing a custom keyboard really messed up scrolling with the webView. Nothing else worked and I resorted to something like this:

    -(void)viewDidLoad{
      [super viewDidLoad];
      [self.webView.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
      self.webView.scrollView.showsVerticalScrollIndicator = NO;
    }  
    
    -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
        if (!CGPointEqualToPoint(self.webView.scrollView.contentOffset, CGPointZero)){
            self.contentOffset = CGPointZero;
        }
    }
    

提交回复
热议问题