gpt4 book ai didi

ios - 大约 10 秒后开始加载 wkwebview 白页

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:54:10 26 4
gpt4 key购买 nike

我想加载一个远程 url 页面,但它总是在大约 10 秒后开始加载代码如下

- (UIWebView *)webView {
if(!_webView) {
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
_webView.scalesPageToFit = YES;
_webView.dataDetectorTypes = UIDataDetectorTypeAll;
_webView.delegate = self;
}
return _webView;
}

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self editNavigationBar];
NSLog(@"viewLodLoad");
self.view.backgroundColor = [UIColor whiteColor];
[self loadHTML:self.pageModel.url title:self.pageModel.postUser];
[self.view addSubview:self.webView];
}
-(void)editNavigationBar {
[self.view addSubview:self.webView];
NSLog(@"start Load WebView");
[self loadWebView];
}


//load URL
- (void)loadHTML:(NSString *)htmlString title:(NSString *)title
{
self.request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:htmlString]];
self.title = title;
[self.webView loadRequest:self.request];
}

但是日志结果是....

2017-01-22 10:04:48.867 xxx[5404:1574257] start Load WebView

2017-01-22 10:04:48.868 xxx[5404:1584402] myQueue

2017-01-22 10:04:48.868 xxx[5404:1574257] viewLodLoad

2017-01-22 10:04:48.946 xxx[5404:1574257] mainQueue

2017-01-22 10:05:01.547 xxx[5404:1574257] decidePolicyForNavigationAction

2017-01-22 10:05:01.548 xxx[5404:1574257] didStartProvisionalNavigation

2017-01-22 10:05:02.468 xxx[5404:1574257] decidePolicyForNavigationResponse

最佳答案

为什么你把所有的 GCD 东西都放在那里?好像没必要。您应该能够将其减少到:

- (void)loadWebView {
[self loadHTML:self.pageModel.url title:self.pageModel.postUser];
}

我打赌这会消除您的 10 秒延迟。

关于ios - 大约 10 秒后开始加载 wkwebview 白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41786697/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com