1

I have a view in my app (iOS7) where a have such a view controllers hierarchy ViewController->childViewController->childViewController->myChildViewController. myChildViewController has a full sized UIWebView on it. I have a UIButton to hide UIToolBar from one of childViewController. When I press the button - UIWebView scrollView changed its content offset by status bar hide. How to avoid this behavior?

2 Answers 2

2

Previously mentioned solution works just fine.

[self addSubview:webView];
self.automaticallyAdjustsScrollViewInsets = NO;
Sign up to request clarification or add additional context in comments.

Comments

0

That should only happen if you've made the UIWebView the main view, such as

viewController.view = webView;

If you make it a subview instead, it should ignore the offsets:

webView.frame = viewController.view.bounds;
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
[viewController.view addSubview:webView];

It may also change if the parent view controller is resized...

Another thing you can try in the view controller that holds the web view:

[viewController setAutomaticallyAdjustsScrollViewInsets:NO];

5 Comments

My 'UIWebView' is not a 'myViewController.view' it's on 'myViewController.view.contentView'. I tried to set "automaticallyAdjustsScrollViewInsets" to 'NO' but that didn't work for me.
What's the type of the view controller?
'UIViewController'->'UINavigationContoroller'->'UIViewController'->'MyViewController with UIWebView'
As far as I know, UIView doesn't have a contentView property... What's the superclass of your MyViewController?
Yes. UIViewController doesn't have contentView property. It's a simple UIView instance above self.view in UIViewController. It is used for simple size manage via margin. But I checked the size and tried to remove all margins from it. That didn't help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.