UIWebView加载

发布于 2024-10-31 14:10:56 字数 1295 浏览 1 评论 0原文

我想在 webview 中加载 html 数据。单击按钮时,它会打开视图控制器并在此视图控制器中加载 html 数据(使用 Interface builder 在此视图控制器中添加 Web 视图)。当 html 数据未正确加载并且我按下后退按钮时,当时应用程序崩溃了。我不做分配&在编码中初始化 webview。使用 Interface builder & 设置 IBOUTLET绑定它。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [connection release];
    NSString *strResponce = [[NSString alloc] initWithData:jsonData_Info encoding:NSUTF8StringEncoding];
    [jsonData_Info release];
    NSError *error;
    SBJSON *json = [[SBJSON new] autorelease];
    self.jsonArray_Info=[json objectWithString:strResponce error:&error];
    str_InfoDetail = [[self.jsonArray_Info objectAtIndex:0] valueForKey:@"Page"];
    str_html = [NSString stringWithFormat:@"%@",str_InfoDetail];
    NSString *temp;
    temp = [NSString stringWithFormat:@"<html><head><style>body{background-color:transparent;}</style></head><body><span style='color:white'>%@</span></body></html>",str_html];
    //web_Information = [[UIWebView alloc]init];
    web_Information.backgroundColor=[UIColor clearColor];
    web_Information.opaque= NO;

    [web_Information loadHTMLString:temp baseURL:nil];  
    [act stopAnimating];
    [strResponce release];  
}

请给我任何解决方案。

谢谢。

I want load the html data in webview. At the button click, it open the viewcontroller and load the html data in this viewcontroller (add web view in this view controller using Interface builder). When the html data not proper loading and i press the back button, at that time crash the app. i am not doing allocation & init webview in the coding. set IBOUTLET using Interface builder & bind it.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [connection release];
    NSString *strResponce = [[NSString alloc] initWithData:jsonData_Info encoding:NSUTF8StringEncoding];
    [jsonData_Info release];
    NSError *error;
    SBJSON *json = [[SBJSON new] autorelease];
    self.jsonArray_Info=[json objectWithString:strResponce error:&error];
    str_InfoDetail = [[self.jsonArray_Info objectAtIndex:0] valueForKey:@"Page"];
    str_html = [NSString stringWithFormat:@"%@",str_InfoDetail];
    NSString *temp;
    temp = [NSString stringWithFormat:@"<html><head><style>body{background-color:transparent;}</style></head><body><span style='color:white'>%@</span></body></html>",str_html];
    //web_Information = [[UIWebView alloc]init];
    web_Information.backgroundColor=[UIColor clearColor];
    web_Information.opaque= NO;

    [web_Information loadHTMLString:temp baseURL:nil];  
    [act stopAnimating];
    [strResponce release];  
}

please give me any solution.

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我只土不豪 2024-11-07 14:10:56

如果您需要答案,请发布一些代码和崩溃日志。从外观上看,我认为这可能是因为您的类中实现了 UIWebView 委托。我认为当您返回时,您不会将委托设为 nil,这可能会导致应用程序崩溃

Pls post some code and crash log if you need answers. By the look of it I think it may be because of implementation of UIWebView delegate in your class. I think when you navigate back you do not make the delegate nil which can cause the app to crash

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文