Hey all, I am presenting a modal view controller and loading a webpage on that view controller in a UIWebView:
- (void)viewWillAppear:(BOOL)animated
{
self.requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:[MPServerPrefs serverPrefs].url_of_sandwich]];
[self.helpWebView loadRequest:self.requestObj];
}
Everything works fine if I let the webpage load and then dismiss the view. If I dismiss the view while the request is loading, I get this stacktrace:
#0 0x31a94466 in objc_msgSend
#1 0x35ebcb70 in -[UIWebView webView:identifierForInitialRequest:fromDataSource:]
#2 0x35ebc1c0 in -[UIWebViewWebViewDelegate webView:identifierForInitialRequest:fromDataSource:]
#3 0x36130d04 in __invoking___
#4 0x36130bd4 in -[NSInvocation invoke]
#5 0x36130730 in -[NSInvocation invokeWithTarget:]
#6 0x329fc2f4 in -[_WebSafeForwarder forwardInvocation:]
I did some searching and can't figure out what's going on. Any ideas? Do I need to cancel my request when dismissing the view controller?
Many thanks!
Silly me - you just need to cancel the request and nil out the delegate!
[self.helpWebView setDelegate:nil];
[self.helpWebView stopLoading];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With