I have a UITabBarController at the bottom of my application and for one view I would like to display many component and I have a UIWebView and at the bottom I have my UITabBarController. My issue is that my UIWebView is cut off at the bottom by my UITabBarController because in my .xib my UIWebView take all the remaining space.

How can I solve that programmatically that my WebView knows when she must stop to display (just before the top of my UITabBarController) ? I would like a solution for IOS6/7 please.

Thank you very much!

有帮助吗?

解决方案

You can set bottom edge inset to your webView.scrollView.

Like:

self.webView.scrollView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, *tabbar_height*, 0.0f);

其他提示

The solution that Kirvoblotsky suggested will work for iOS 7.0 but not on iOS 7.1. On iOS7.1 your web view will have an additional inset on top of bottom tab bar.

In the view controller that contains your web view you need to add this modification:

-(void) viewDidLoad {
    ...
    // put this IF statemenet in the end
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        [self setEdgesForExtendedLayout:UIRectEdgeNone];
    }
}

If you don't do it like this then you need to do if statement when setting contentInset:

if (*iOS version == 7.1*) {
    self.webView.scrollView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, 0.f, 0.0f);
} else if (*iOS version == 7.0) {
    self.webView.scrollView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, *tabbar_height*, 0.0f);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top