is there a better way than this? The loadRequest in the killWebView method is a hack to get rid of webPages like youtube. I dont want to do it like that, but i cannot find any documentation on how to unload the WebView…
- (IBAction)killWebView:(id)sender
{
[self.webView stopLoading];
[self.webModal setHidden:YES];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
}
- (IBAction)viewVideoLink:(id)sender
{
self.webModal.backgroundColor = [self randomColor:.4];
[self.webModal setHidden:NO];
NSString *strWebsiteUlr = [NSString stringWithFormat:[NSString stringWithFormat:@"%@", [self.model.currentTrackDictionary objectForKey:@"video_url"]]];
NSURL *url = [NSURL URLWithString:strWebsiteUlr];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
}
You are releasing self.webView, then two lines later, you’re sending a message to self.webView. That will cause a crash.