Seems UIWebView starts it's own thread when loading a webpage, and if I dismiss the view while this is going on the app will crash.
I've tried doing [webView stopLoading] before dismissing (presenting it as a modal view now), but that doesn't seem to help.
Here's my WebViewer.m:
And WebViewer.h:
Anybody got a suggestion as to what to do here?
I've tried doing [webView stopLoading] before dismissing (presenting it as a modal view now), but that doesn't seem to help.
Here's my WebViewer.m:
Code:
#import "WebViewer.h"
@implementation WebViewer
@synthesize scalesPageToFit;
@synthesize webView;
- (id)initWithURL:(NSURL *)URL
{
if(self = [super init])
{
webURL = URL;
scalesPageToFit = YES;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:webURL];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (IBAction)closeWebView
{
[webView stopLoading];
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
- (void)dealloc {
NSLog(@"Dealloc called for WebViewer");
[super dealloc];
}
@end
And WebViewer.h:
Code:
#import <UIKit/UIKit.h>
@interface WebViewer : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *webView;
BOOL scalesPageToFit;
NSURL *webURL;
}
@property (nonatomic, retain) UIWebView *webView;
@property (nonatomic) BOOL scalesPageToFit;
- (id)initWithURL:(NSURL *)URL;
- (IBAction)closeWebView;
@end
Anybody got a suggestion as to what to do here?