Added whitespace in UIWebview - removing UIWebView whitespace in iOS7 & iOS8

前端 未结 6 2080
鱼传尺愫
鱼传尺愫 2020-12-13 18:43

Im loading local html files, since iOS7 there is added white space on top in the UIWebView.(I cant post an image as i do not have enough points.) image can be seen here- sna

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 18:58

    One alternative to Jeff Kranenburg's method is to subclass and override the UIWebView subclasses' UIScrollViewDelegate method scrollViewDidScroll:. This is only appropriate if scrolling is turned off for your subclass.

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
      if ([[self superclass] instancesRespondToSelector:_cmd]) {
        [super scrollViewDidScroll:scrollView];
      }
    
      [self fixUpScrollViewContentOffset];
    }
    
    - (void)fixUpScrollViewContentOffset
    {
      if (!CGPointEqualToPoint(self.scrollView.contentOffset, CGPointZero)) {
        self.scrollView.contentOffset = CGPointZero;
      }
    }
    

提交回复
热议问题