remove webview before call another webview

Discussion in 'iPhone/iPad Programming' started by imaumac, Dec 22, 2008.

  1. macrumors member

    Joined:
    Oct 15, 2008
    #1
    Please:
    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.

    http://www.1572-8.com/zzz-xcode-testing/skeleton-html.zip

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

    xsmasher

    Joined:
    Jul 18, 2008
    #2
    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. thread starter macrumors member

    Joined:
    Oct 15, 2008
    #3
    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.

    note:
    here is my main code on Delegate.m

     
  4. macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #4
    Code:
    if (webView != nil)
    [webView release];
    webView = [[UIWebView alloc] initWithFrame:[myHTML_ojo1 bounds]];
    //and
    [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.

    Code:
    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. thread starter macrumors member

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

Share This Page