I am having memory leaks that I cannot understand due to leaks, assembly / analysis or a general inspection of how to repair. I have a very strong idea that this is due to the loadRequest command from my UIWebview loading javascript, but I cannot figure out what is wrong.
Here is my setup:
I have a tabbarcontroller that I programmatically create with 4 view controllers: a table view, mapview, another table view, and webview, respectively.
- The first view of the table displays static data.
- mapview shows annotations that, when clicked, fill the fourth tab variable, webview, and switch to webview to display a locally saved html / javascript file, which is a 3d model.
- The 2nd table is a list of all the same information, each annotation in mapview is just a table. it has the same functionality in terms of filling in a variable, switching and displaying an html / javascript file in webview
- webview displays the downloaded html / javascript file if it does not show UIAlertView to select it from mapview or list
loadRequest() webview, . , 3d- (.. , , x, -, , y ( x ) ââ-). ipad, . : General-Block 56, 1024, 8, 244 24 , .
webview, loadrequest loadrequest request = nil, , url, ( google.com, javascript), .
:
- [self.webView loadRequest: nil];
- [self.webView loadHTMLString: @"" baseURL: nil];
- [self.webView stopLoading];
viewWillDisappear webViewController, - , , , . loadRequest, .
- fyi, xcode 4.0.2, ipad , 4.3.2
- , ( ), , , - , javascript
- html javascript, . , cfnetwork/http, , .
, mapView, loadModel webViewController:
- (void) mapCallOutPressed: (UIView *) sender {
NSInteger selectedIndex = sender.tag;
MyLocation *selectedObject = [_mapView.annotations objectAtIndex:selectedIndex];
MyModel *model = selectedObject.model;
NSLog(@"Model selected from mapview = %@", model.description);
WebViewController *webViewController = [self.tabBarController.viewControllers objectAtIndex:3];
webViewController.model = model;
[webViewController loadModel];
self.tabBarController.selectedIndex = 3;
[self.tabBarController.selectedViewController viewDidAppear:YES];
webViewController.h .m:
WebViewController.h:
WebViewController : UIViewController <UIWebViewDelegate> {
UIWebView *webView;
NSString *templateRunFilePath;
MyModel *model;
NSString *templateRunTitle;
@property (nonatomic, retain) UIWebView *webView;
@property (assign) MyModel *model;
@property (nonatomic, copy) NSString *templateRunFilePath;
@property (nonatomic, copy) NSString *templateRunTitle;
-(void) loadModel;
WebViewController.m:
- (void) viewDidLoad {
[super viewDidLoad];
NSLog(@"in webview did load");
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
self.webView.delegate = self;
self.webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
self.webView.scalesPageToFit = YES;
[self.view addSubview:self.webView];
}
- (void) viewWillAppear:(BOOL)animated {
if (self.model) {
self.tabBarController.navigationItem.title = [NSString stringWithFormat: @"%@ - %@", self.tabBarController.navigationItem.title, self.model.description];
}
else {
UIAlertView *msg = [[UIAlertView alloc] initWithTitle:@"No Model Selected"
message:@"Please select a model from the map or list tab to view."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[msg show];
[msg release];
}
}
- (void) loadModel {
NSString *localURLPath = [NSString stringWithFormat:@"%@/%@/%@", self.templateRunFilePath, self.model.folderName, self.model.modelFileName];
NSURL *url = [NSURL fileURLWithPath:localURLPath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL: url];
[self.webView loadRequest:requestObj];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
}
-(void)viewWillDisappear:(BOOL)animated {
NSLog(@"webview view will disappear");
[super viewWillDisappear:animated];
self.webView.delegate = nil;
}
- (void)dealloc {
self.webView.delegate = nil;
[self.webView release];
[super dealloc];
}
- , . < 1 , , , .
!
-Mike