I have a UIViewController that contains a UIWebView .
i go to the site to tell facebook using the UIWebview in the UIViewController, after which I click on done which reject the view controller, which I suppose will free the view controller. but when I reopen UIWebview (without leaving the application, and even after the application is completed), the webpage still logs into Facebook after the webview is loaded. How should I let go of the web view so that every time I click the "Done" button and return back to the web view, the web view will always be reminiscent of the "new" and not the login on any website to which I entered earlier.
- (void)viewDidLoad{ NSLog(@"webView viewDidLoad called"); appDelegate = (LoginDBAppDelegate *)[[UIApplication sharedApplication] delegate]; loginObj = [appDelegate.loginArray objectAtIndex:currentSelectedRow]; myWebView.delegate = self; [super viewDidLoad]; [self showWebView]; } -(void)showWebView{ NSLog(@"webView showWebView called"); NSURL *url = [NSURL URLWithString:loginObj.loginURL]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [myWebView loadRequest:request]; } -(IBAction)done_Clicked:(id)sender{ NSLog(@"webView Done_Clicked");
I tried this, but this did not work:
-(IBAction)done_Clicked:(id)sender{ NSLog(@"webView Done_Clicked"); [[NSURLCache sharedURLCache] removeAllCachedResponses]; [myWebView stringByEvaluatingJavaScriptFromString:@"var body=document.getElementsByTagName('body')[0];body.style.backgroundColor=(body.style.backgroundColor=='')?'white':'';"]; [myWebView stringByEvaluatingJavaScriptFromString:@"document.open();document.close()"];
I also tried this without any success:
- (void) viewDidDisappear:(BOOL)animated { NSLog(@"webView viewDidDisappear called"); [super viewDidDisappear:animated]; [self.myWebView removeFromSuperview]; self.myWebView.delegate = nil; self.myWebView = nil; [myWebView release]; }
source share