【发布时间】:2011-08-03 15:47:35
【问题描述】:
我想在 webview 中加载 html 数据。单击按钮时,它会打开视图控制器并在此视图控制器中加载 html 数据(使用界面生成器在此视图控制器中添加 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];
}
请给我任何解决方案。
谢谢。
【问题讨论】:
标签: iphone objective-c uiwebview