remove webview before call another webview

Discussion in 'iOS Programming' started by imaumac, Dec 22, 2008.

  1. imaumac macrumors member

    Oct 15, 2008
    how should I remove a webView when call another ?

    if I run my small app with activity monitor (instruments)
    you can see each time you call a webView then the memory increases, and add 4 or 5 MB each time pressing the button (calling a local HTML)

    my question is:
    how can I remove a webView before call another webView please.

    here is the url of the small proyect to see see the problem.

    please help , and one more time thanks.
  2. xsmasher macrumors regular


    Jul 18, 2008
    I did not download your code - but are you creating a whole new webview each time? I would create a single webview, and just load new content into it. It'll probably be faster too.
  3. imaumac thread starter macrumors member

    Oct 15, 2008
    I try , but not works, it crash again when run on device.
    please, I begging you, to help with this.

    this is the new project updated, but crash again if run for 4 or 5 minutes. (on device)
    could you tellme how use the same Webview and load new content in to it? please ?

    or where can I find information to do it please ?
    I realy , realy need it.

    here is my main code on Delegate.m

  4. xsmasher macrumors regular


    Jul 18, 2008
    if (webView != nil)
    [webView release];
    webView = [[UIWebView alloc] initWithFrame:[myHTML_ojo1 bounds]];
    [myHTML_ojo1 addSubview:webView];	
    That's the code that makes a whole new webView - don't do this when you click the button. Do it once when the view is first shown.

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"head-mandiblev" ofType:@"html"];
    NSString *html = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    [webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath] isDirectory:YES]];
    That's the code that loads the HTML into the view. That's the stuff that you want to do when the button is pushed.
  5. imaumac thread starter macrumors member

    Oct 15, 2008
    now is working... 7 days searching this.
    thanks , vry thanks for your valuable help.!

Share This Page