if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {self.automaticallyAdjustsScrollViewInsets = NO;}
或者:_webView.opaque =NO;
具体场景如下:
- (void)viewDidLoad {
self.title = @"菜品详情页";
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
//加载web页面
[self addWebViewDemo];
}
-(void)addWebViewDemo{
_webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, JYEScreenWidth, JYEScreenHeight-64)];
NSURL *url = [[NSURL alloc]initWithString:@"http://www.baidu.com"];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
[_webView loadRequest:request];
//if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {self.automaticallyAdjustsScrollViewInsets = NO;}
_webView.opaque =NO;
_webView.scalesPageToFit = YES;
[self.view addSubview:_webView];
}