UIWebView加载
我想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要答案,请发布一些代码和崩溃日志。从外观上看,我认为这可能是因为您的类中实现了 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