UIWebview scrollview changes contentsize for no re

2019-05-08 02:29发布

问题:

I have a uiviewcontroller which loads a uiwebview. When the uiviewcontroller loads the uiwebview everything is done correctly. But when one navigates away and returns back and the uiwebview is not loaded, it is displayed differently. The uiwebview scrollview's contentsize height changes by 64px, it gets higher.

When it is loaded for the first it looks like this

When one returns back to the view, this is what happens

I hope I was able to make my problem understandable. If more details are necessary, I am able to give more. Thank you

回答1:

I had a similar problem, try this code in your viewDidLoad method.

if([self respondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)])
    self.automaticallyAdjustsScrollViewInsets = NO;


回答2:

You can do like this.
- (void) viewDidLoad { [super viewDidLoad]; self.automaticallyAdjustsScrollViewInsets = NO; }