美文网首页
解决 iOS 11 webview 顶部空白条的问题

解决 iOS 11 webview 顶部空白条的问题

作者: sunny_ling | 来源:发表于2019-08-25 09:22 被阅读0次

    - (void)viewDidLoad {

        [super viewDidLoad];

        self.automaticallyAdjustsScrollViewInsets=NO;

        webView = [[UIWebView alloc] initWithFrame:self.view.frame];

        [self.view addSubview:webView];

        NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];

        NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

        [webViewloadRequest:request];

        //解决 iOS 11 屏幕顶部显示不全

        if(@available(iOS11.0, *)) {

            webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

        }else{

            // Fallback on earlier versions

        }

    }

    相关文章

      网友评论

          本文标题:解决 iOS 11 webview 顶部空白条的问题

          本文链接:https://www.haomeiwen.com/subject/qbqhectx.html