Non*_*oto 3 javascript css iphone uiwebview
我想使用Javascript在UIWebview上添加填充,因为我在全屏和导航栏模式之间切换视图,导航栏隐藏了原始页面的顶部.
这是代码.它适用于某些页面,但在某些页面上不起作用.有没有人想让它在所有页面上都有效?
- (void)webViewDidFinishLoad:(UIWebView*)webView {
//make padding on the top and the bottom of webview
NSString *padding = @"document.body.style.padding='64px 0px 44px 0px';";
[webView_ stringByEvaluatingJavaScriptFromString:padding];
}
Run Code Online (Sandbox Code Playgroud)
它在这个页面上工作正常.(左图)http://pandodaily.com/2012/03/23/jessica-albas-the-honest-company-raises-27-million-for-non-toxic-baby-products/

我的朋友告诉我更好的解决方案,所以我想分享一下.
- (BOOL)iOS5OrHigher {
NSString *iOSversion = [[UIDevice currentDevice] systemVersion];
if ([iOSversion compare:@"5.0" options:NSNumericSearch] != NSOrderedAscending) {
return YES;
} else {
return NO;
}
}
if ([self iOS5OrHigher]) {
webView_.scrollView.contentInset = UIEdgeInsetsMake(44.0,0.0,44.0,0.0);
} else {
UIScrollView *scrollview = (UIScrollView *)[webView_.subviews objectAtIndex:0];
scrollview.contentInset = UIEdgeInsetsMake(44.0,0.0,44.0,0.0);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4951 次 |
| 最近记录: |