UIWebView 崩溃应用程序
这是我的代码,它们一起使我的应用程序崩溃
为 webview 分配其值的位:它工作正常,直到最后一行。当它发出信号时。
[cell setLabelText:[cellTitle objectAtIndex:indexPath.row]];
[cell imagesetter:[imageTitle objectAtIndex:indexPath.row]];
[cell desSetter:[desTitle objectAtIndex:indexPath.row]];
[cell changeProductWeb:[webTitle objectAtIndex:indexPath.row]];
数组
webTitle = [[NSArray alloc] initWithObjects:
@"http://www.google.com/",
@"http://www.google.com/",
@"http://www.google.com/",
@"http://www.google.com/",
nil];
操作
- (IBAction) changeProductWeb:(NSString *)str{
NSURL *url = [NSURL URLWithString:str];
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
这是唯一导致程序崩溃的位。当我删除它时,它不会崩溃。
This is my Code that all together crashes my app
The bit that assigns the webview its value: It works fine until the last line. When it SIGBARTS.
[cell setLabelText:[cellTitle objectAtIndex:indexPath.row]];
[cell imagesetter:[imageTitle objectAtIndex:indexPath.row]];
[cell desSetter:[desTitle objectAtIndex:indexPath.row]];
[cell changeProductWeb:[webTitle objectAtIndex:indexPath.row]];
The Array
webTitle = [[NSArray alloc] initWithObjects:
@"http://www.google.com/",
@"http://www.google.com/",
@"http://www.google.com/",
@"http://www.google.com/",
nil];
The action
- (IBAction) changeProductWeb:(NSString *)str{
NSURL *url = [NSURL URLWithString:str];
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
This is the only bit the crashes the program. When I remove it it wont crash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要在某个时候调用 [webView keep]。如果你的 webView 没有被你的类占用,你会得到这样的 SIGABART。
一个简单的解决方案是在您的 .h 文件中使用它:
然后在您的 .m 文件中:
然后,无论您在哪里引用您的 webview,请确保添加“self”
You probably need to call [webView retain] at some point. You would get a SIGABART like that if your webView is not being held onto by your class.
A simple solution is to use this in your .h file:
Then in your .m file go:
Then, wherever you refer to your webview, make sure to add "self"