gpt4 book ai didi

ios - UIWebview loadHTMLString 不想显示

转载 作者:行者123 更新时间:2023-11-29 04:34:25 25 4
gpt4 key购买 nike

为了解决 ios 中链接的 UITextview 蓝色问题(我想要白色的),我在自定义弹出窗口中实现了 UIWebview

在我的弹出 Controller 中,我有以下代码( uiwebview 设置为隐藏在 xib 中)

- (void) showWebView:(NSString *)htmlText{
[webView setHidden:FALSE];
[txtContent setHidden:TRUE];

NSString * htmlString = [NSString stringWithFormat:@"<html><head><style type='text/css'>body {background-color:transparent; } p { color:white; font-family:Helvetica; font-size:14px; } a { color:white; }</style></head><body><p>%@</p></body></html>", htmlText];
webView.delegate = self;

NSLog(@"htmlstring %@",htmlString);
[webView loadHTMLString:htmlString baseURL:nil];

}

(txtContent 是我隐藏的 uiTextview)

在我的主 Controller 中,我有以下内容:

SwbPopup * popup =  [[SwbPopup alloc] initWithNibName:@"SwbPopup" bundle:nil];

[[self.view superview] addSubview:popup.view];
popup.view.center = CGPointMake([self.view superview ].center.y, [self.view superview].center.x - ([self.view superview].frame.size.width / 4) );


[popup showWebView:popupBloodglucoseLevel];

(popbloodglucoselevel 是一个包含我的带有链接的弹出消息的字符串)

当我不在 xib 中隐藏 webview 时,它确实会显示(每次),但也不想加载 html....

更新我实现了以下所有委托(delegate)方法,但没有一个被调用:s

    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
//[myActivityIndicatorView stopAnimating];

NSLog(@"ERROR");
NSLog([NSString stringWithFormat: @"%d", [error code]]);
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@"Started loading");
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLog(@"Finished loading");

}

最佳答案

您是否尝试过实现

[– webView:didFailLoadWithError:][1]

在您的委托(delegate)中查看加载 HTML 时发生了什么?

在 iOS5 下,我发现有时 UIWebView 不会加载其内容

<meta charset="utf-8"></meta>

(或其他等效的字符集规范)未出现在 HTML 中。

关于ios - UIWebview loadHTMLString 不想显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11259338/

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