Ios 运行UIWebView时收到内存警告
我现在正在开发一个Iphone应用程序,它要求用户登录Facebook,将他们的数据传递到webService,然后登录到我的游戏。基本上,我的游戏是通过HTML运行的,它将通过UIWebView在我的应用程序中显示 以下是我加载webView的代码:Ios 运行UIWebView时收到内存警告,ios,objective-c,uiwebview,Ios,Objective C,Uiwebview,我现在正在开发一个Iphone应用程序,它要求用户登录Facebook,将他们的数据传递到webService,然后登录到我的游戏。基本上,我的游戏是通过HTML运行的,它将通过UIWebView在我的应用程序中显示 以下是我加载webView的代码: -(void)callWebView { self.webView.delegate = self; NSURL *url = [NSURL URLWithString:@"http://www.my_game_url"]; NSURLReque
-(void)callWebView {
self.webView.delegate = self;
NSURL *url = [NSURL URLWithString:@"http://www.my_game_url"];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestURL];
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
if ( [ urlString isEqualToString: @"http://my_game_logout_url" ] ) {
[myWebView stopLoading];
[self.webView removeFromSuperview];
MyAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.session closeAndClearTokenInformation];
[FBSession.activeSession close];
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
[[NSUserDefaults standardUserDefaults] synchronize];
return NO;
}
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[self.webView stopLoading];
MyAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.session closeAndClearTokenInformation];
[FBSession.activeSession close];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
webView.delegate = nil;
[webView stopLoading];
}
- (void)dealloc {
[webView setDelegate:nil];
}
可以使用UIWebView运行我的游戏。问题是我将稍后收到内存警告,我的应用程序将崩溃。我必须启用自动引用计数(ARC)来自动释放一些不需要的源,但我仍然会在我的应用程序中收到内存警告。我有什么错吗?
谢谢
将有所帮助。在Instruments+heapshots中使用分配=>