Memory warning when loading google map in UIWebVie

2019-09-08 11:51发布

问题:

In my app UIWebView loads Google maps, while using this Direction url == http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=37.774930,-122.419415&daddr=37.7655277,-122.421811&ie=UTF8&z=12,

it throws "Received memory warning" and my app crash.

UIWebview is a subview of UIView in my view controller. I took it as a IBOutlet.

Pls help me with this, it creates lots of trouble for my app.

Thank you in advance...

回答1:

Is your app actually crashing (does the Xcode debugger catch it? can you post the stack trace of the thread which crashed), or is it being shut down by the OS for using too much memory?

You might also try reproducing the crash with NSZombieEnabled - check the Xcode docs for the details on how to do this.



回答2:

.h ///---- #import

@interface WebsiteViewController : UIViewController <UIWebViewDelegate>

{

IBOutlet UIWebView *webView;

}

@property(nonatomic,retain) IBOutlet UIWebView *webView;

.m ///---

-(void)viewDidLoad {
     NSURLRequest *request = [[NSURLRequest alloc] initWithURL:@"url"];
[self.webView setScalesPageToFit:YES];
[self.webView loadRequest:request];
[request release]; 
}