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 childViewControlle
r. When I press the button - UIWebView
scrollView
changed its content offset
by status bar
hide. How to avoid this behavior?
Asked
Active
Viewed 1,467 times
1

Anbu.Karthik
- 82,064
- 23
- 174
- 143

Alexander Slabinsky
- 681
- 8
- 23
2 Answers
2
Previously mentioned solution works just fine.
[self addSubview:webView];
self.automaticallyAdjustsScrollViewInsets = NO;

Armands Antans
- 478
- 4
- 13
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];

jjv360
- 4,120
- 3
- 23
- 37
-
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. – Alexander Slabinsky Nov 14 '14 at 13:36
-
What's the type of the view controller? – jjv360 Nov 14 '14 at 13:38
-
'UIViewController'->'UINavigationContoroller'->'UIViewController'->'MyViewController with UIWebView' – Alexander Slabinsky Nov 14 '14 at 13:58
-
As far as I know, `UIView` doesn't have a `contentView` property... What's the superclass of your `MyViewController`? – jjv360 Nov 14 '14 at 14:02
-
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. – Alexander Slabinsky Nov 16 '14 at 23:10