PDA

View Full Version : remove webview before call another webview




imaumac
Dec 22, 2008, 10:06 AM
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.



xsmasher
Dec 23, 2008, 11:20 AM
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.

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.

imaumac
Dec 23, 2008, 02:07 PM
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 (http://www.1572-8.com/zzz-xcode-testing/skeleton-2u-html.zip) 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

#import "skeletonAppDelegate.h"
#import "skeletonViewController.h"
@implementation skeletonAppDelegate

- (IBAction)IBAc_ojo1: (id)sender {
[jpg_hide setHidden:NO];
if (webView != nil)
[webView release];
webView = [[UIWebView alloc] initWithFrame:[myHTML_ojo1 bounds]];
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]];
[webView setScalesPageToFit:YES];
[myHTML_ojo1 addSubview:webView];
[butt_return_partes setHidden:NO];
[butt_return_menu setHidden:YES];
[bt_HEAD_mandible setHidden:YES];
[bt_html_2 setHidden:YES]; }

- (IBAction)IBAc_html_2: (id)sender {
[jpg_hide_2 setHidden:NO];
if (webView != nil)
[webView release];
webView = [[UIWebView alloc] initWithFrame:[myHTML_ojo2 bounds]];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"head-mandiblew" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath] isDirectory:YES]];
[webView setScalesPageToFit:YES];
[myHTML_ojo2 addSubview:webView];
[butt_return_partes setHidden:NO];
[butt_return_menu setHidden:YES];
[bt_HEAD_mandible setHidden:YES];
[bt_html_2 setHidden:YES]; }

- (IBAction)IBAc_ojo1_hide: (id)sender {
[jpg_hide setHidden:YES];
[jpg_hide_2 setHidden:YES];
[butt_return_partes setHidden:YES];
[butt_return_menu setHidden:NO];
[bt_HEAD_mandible setHidden:NO];
[bt_html_2 setHidden:NO]; }

@synthesize window;

xsmasher
Dec 23, 2008, 02:24 PM
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.


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.

imaumac
Dec 23, 2008, 06:09 PM
now is working... 7 days searching this.
thanks , vry thanks for your valuable help.!