UIWebView Crashing App
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:(开发者_如何学PythonNSString *)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.
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:
@property (nonatomic,retain) UIWebView *webView;
Then in your .m file go:
@synthesize webView;
Then, wherever you refer to your webview, make sure to add "self"
[self.webView loadRequest:requestObj];
精彩评论