日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2024/4/18 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决 iOS 11 webview 顶部空白条的问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在 iOS 11 使用 webview 發現頂部會有一個空白條,怎么也去不掉,通過設置 contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever 就可以解決了,具體的代碼如下:

// // ViewController.m // webView // // Created by exchen on 18/7/14. // Copyright ? 2018年 exchen. All rights reserved. //#import "ViewController.h"@interface ViewController () <UIWebViewDelegate>@property(nonatomic, strong) UIWebView* webView; @end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.CGRect screen = [[UIScreen mainScreen] bounds];//添加 UIWebViewself.webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, screen.size.width, screen.size.height)];[self.view addSubview: self.webView];NSURL * url = [NSURL URLWithString: @"https://www.exchen.net"];NSURLRequest * request = [NSURLRequest requestWithURL:url];[self.webView loadRequest:request];self.webView.delegate = self;//解決 iOS 11 屏幕頂部顯示不全if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;}}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }- (void)webViewDidStartLoad:(UIWebView *)webView {NSLog(@"%@",NSStringFromSelector(_cmd)); }//加載失敗時調用 - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {NSLog(@"%@",NSStringFromSelector(_cmd));NSLog(@"error: %@",error);UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"信息" message:@"連接服務器失敗,請檢查網絡" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){exit(0);}];[alertController addAction:cancelAction];[self presentViewController:alertController animated:YES completion:nil]; }- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{return true; }@end

原文地址:https://www.exchen.net/%E8%A7%A3%E5%86%B3-ios-11-webview-%E9%A1%B6%E9%83%A8%E7%A9%BA%E7%99%BD%E6%9D%A1%E7%9A%84%E9%97%AE%E9%A2%98.html

總結

以上是生活随笔為你收集整理的解决 iOS 11 webview 顶部空白条的问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。