2011-06-10 13 views
5

Hola estoy teniendo problemas con una fuga de UIWebView básicamente tengo mis páginas de visualización WebView con los enlaces en una UITableView de otro controlador. Empujo el controlador con WebView con un navegador y paso el enlace con un retenerle propiedad.IOS UIWebView Fuga

He intentado todo en Internet, como:

[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"]; 

//Clear cache of UIWebView 
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; 
[NSURLCache setSharedURLCache:sharedCache]; 
[sharedCache release]; 
sharedCache = nil; 
[[NSURLCache sharedURLCache] removeAllCachedResponses]; 

este es mi código:

-(void) viewWillAppear:(BOOL) animated 
{ 
    NSMutableURLRequest *_req=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:link] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:120]; 

    [_req setHTTPShouldHandleCookies:NO]; 
    [self setMyRequest:_req]; 
    [req release]; 
} 

[webView loadRequest:myRequest]; 

-(void) viewWillDisappear:(BOOL) Animated 
{ 
    [webView stopLoading]; 
    [webView loadHTMLString:@"<html></html>" baseURL:nil]; 
} 

- (void)dealloc { 
    [myRequest release]; 
    [webView stopLoading]; 
    [webView release]; 
    [link release]; 
    [super dealloc]; 
} 

Ahora solo probé en el simulador 4.2 y 4.3, uso xcode 4, obtengo estas fugas cuando presiono el botón Atrás en el navegador.

Y aquí es el código de mi controlador tableview

- (void)viewDidLoad { 
    webViewController=[[ItemDetail alloc] initWithNibName:@"ItemDetail" bundle:[NSBundle mainBundle] ]; 

    [super viewDidLoad]; 
} 


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    webViewController.link=http://www.myLink.com; 
    [self.navigationController pushViewController:webViewController animated:YES]; 

} 

-(void) dealloc 
{ 
    [webViewController release]; 
    ... 
    ... 
    [super dealloc]; 
} 

Aquí hay un enlace a una pantalla: http://postimage.org/image/368r0g0xw/

Cualquier ayuda se agradece, Gracias

+0

Una de sus líneas de código aparece fuera de cualquier método, ¿puede publicar su código real? Eso no compilará ¿Dónde se asigna/asigna 'myRequest'? ¿Qué pasa con 'link'? ¿Has configurado un delegado para el 'UIWebView'? – Jim

+0

lo siento, seguro que voy a publicar el código ahora –

Respuesta

1
-(void) viewWillAppear:(BOOL) Animated 
{ 
    //CONNECTION INIT 
    [web setDelegate:self]; 

    NSURL *url=[[NSURL alloc] initWithString:link]; 

    NSURLRequest *_req=[[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:120]; 

    [self setReq:_req]; 

    [_req release]; 
    [url release]; 
    [web loadRequest:req]; 


} 

-(void) viewWillDisappear:(BOOL) Animated 
{ 
    [self setReq:nil]; 
    if ([web isLoading]) 
    [web stopLoading]; 
    [web setDelegate:nil]; 
} 

- (void)dealloc { 
    [req release]; 
    [map release]; 
    [web setDelegate:nil]; 
    [web release]; 
    [link release]; 
    [super dealloc]; 
} 

Ahora i liberarlo después de volver a la vista de tabla, todavía deja unos 3 mb después de que lo publique, pero ahora cuando creo la vista otra vez y la lanzo aga en esos 3mb no se modifican. Weird ...

Item Detail *webViewController=[[ItemDetail alloc] initWithNibName:@"ItemDetail" bundle:[NSBundle mainBundle] ]; 


    [self.navigationController pushViewController:webViewController animated:YES]; 
    [webViewController release]; 
Cuestiones relacionadas