tutorial open example crear ios objective-c iphone uiwebview

open - webview ios swift example



Bloqueo aleatorio de UIWebView en[UIViewAnimationState release]: mensaje enviado a la instancia desasignada (8)

Este trabajo alrededor parece arreglarlo para mi aplicación. No me siento cómodo con esto, pero actualmente es lo único que he podido averiguar para deshacerme del accidente.

[self.webView performSelector: @selector (loadRequest :) withObject: urlRequest] afterDelay: 0.5];

O, si quieres algo más seguro, puedes usar WKWebView en iOS 8+

Como WKWebView no admite archivos locales, inicie un servidor web:

[GCDWebServer setLogLevel:4]; webServer = [[[GCDWebServer alloc] init] retain]; [webServer addGETHandlerForBasePath:@"/" directoryPath:rootDir indexFilename:@"index.html" cacheAge:3600 allowRangeRequests:YES]; [webServer startWithPort:0 bonjourName:nil];

Luego, dependiendo de la versión del sistema operativo, cree su vista web:

if (NSClassFromString(@"WKWebView")) { NSString* jScript = @""; WKUserScript* wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES]; WKUserContentController* wkUController = [[WKUserContentController alloc] init]; [wkUController addUserScript:wkUScript]; WKWebViewConfiguration* wkWebConfig = [[WKWebViewConfiguration alloc] init]; wkWebConfig.userContentController = wkUController; webViewNew = [[WKWebView alloc] initWithFrame:CGRectMake(0.f, 0.f, 1.f, 1.f) configuration:wkWebConfig]; webViewNew.navigationDelegate = self; webViewNew.scrollView.bounces = NO; webViewNew.scrollView.scrollEnabled = NO; webViewNew.backgroundColor = [UIColor redColor]; webViewNew.opaque = YES; } else { webViewOld = [[UIWebView alloc] initWithFrame: CGRectMake (0, 0, 1.0f, 1.0f)]; webViewOld.delegate = self; [[webViewOld scrollView] setBounces: NO]; webViewOld.scrollView.scrollEnabled = NO; webViewOld.scalesPageToFit = YES; [webViewOld setBackgroundColor:[UIColor whiteColor]]; [webViewOld setOpaque:NO]; }

Y luego vaya a: [NSString stringWithFormat: "htztp: //127.0.0.1:% d", (int) webServer.port] (Ignore la z en el http, stackoverflow no me deja publicar URL en localhost)

Estoy teniendo un UIWebView aleatorio de UIWebView usando iOS8.1 y UIWebView , usando un iPhone5 . En mis pruebas el fallo no aparece en iOS7 .

He creado este repositorio github para reproducir el bloqueo: https://github.com/crarau/WebViewCrash

Básicamente estoy agregando un UIWebView y cargando www.amazon.com

Aleatoriamente, la aplicación se bloquea en WebThread con EXC_ARM_BREAKPOINT

Después de habilitar Zombie tracking en la consola, aparece este mensaje:

[UIViewAnimationState release]: message sent to deallocated instance 0x14deff70

Aquí lo que sucede en la carga de UIView :

[super viewDidLoad]; NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.amazon.com"]]; self.webView.layer.cornerRadius = 0; self.webView.userInteractionEnabled = YES; self.webView.multipleTouchEnabled = YES; self.webView.backgroundColor = [UIColor clearColor]; self.webView.scrollView.scrollEnabled = NO; self.webView.scrollView.bounces = NO; [self.webView loadRequest:urlRequest];

La excepción stacktrace:

Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x000000000000defe Triggered by Thread: 2 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0: 0 libsystem_kernel.dylib 0x2fe054f0 mach_msg_trap + 20 1 libsystem_kernel.dylib 0x2fe052e4 mach_msg + 36 2 CoreFoundation 0x21fed936 __CFRunLoopServiceMachPort + 142 3 CoreFoundation 0x21febedc __CFRunLoopRun + 1012 4 CoreFoundation 0x21f3a20c CFRunLoopRunSpecific + 472 5 CoreFoundation 0x21f3a01e CFRunLoopRunInMode + 102 6 GraphicsServices 0x293330a4 GSEventRunModal + 132 7 UIKit 0x255461cc UIApplicationMain + 1436 8 WebViewCrash 0x0002deec main (main.m:14) 9 libdyld.dylib 0x2fd52aac start + 0 Thread 1 name: Dispatch queue: com.apple.libdispatch-manager Thread 1: 0 libsystem_kernel.dylib 0x2fe052a0 kevent64 + 24 1 libdispatch.dylib 0x00162674 0x154000 + 58996 2 libdispatch.dylib 0x00157496 0x154000 + 13462 Thread 2 name: WebThread Thread 2 Crashed: 0 CoreFoundation 0x2202aea2 ___forwarding___ + 534 1 CoreFoundation 0x21f5cdf4 _CF_forwarding_prep_0 + 20 2 CoreFoundation 0x21f2ee58 CFRelease + 596 3 QuartzCore 0x24f0ba60 CA::release_objects(X::List<void const*>*) + 12 4 QuartzCore 0x24f10dc2 -[CAAnimation dealloc] + 50 5 libobjc.A.dylib 0x2f7ecd5a objc_object::sidetable_release(bool) + 162 6 libobjc.A.dylib 0x2f7ed1a4 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 400 7 CoreFoundation 0x21fee2a4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12 8 CoreFoundation 0x21fede1e __CFRunLoopDoTimer + 646 9 CoreFoundation 0x21fec06e __CFRunLoopRun + 1414 10 CoreFoundation 0x21f3a20c CFRunLoopRunSpecific + 472 11 CoreFoundation 0x21f3a01e CFRunLoopRunInMode + 102 12 WebCore 0x2d362ebe RunWebThread(void*) + 414 13 libsystem_pthread.dylib 0x2fe95e90 _pthread_body + 136 14 libsystem_pthread.dylib 0x2fe95e02 _pthread_start + 114 15 libsystem_pthread.dylib 0x2fe93b8c thread_start + 4

Cualquier consejo es apreciado gracias


Estoy experimentando el mismo problema en iOS 8 y más específicamente un iPad 3 falla mucho más a menudo que otros.

Según su publicación y un par de otras que pude encontrar, parece que es un problema con UIWebView solo en iOS8, ya que funciona en iOS7.

Lo que he hecho es usar el nuevo WKWebView en iOS8, que no presenta el mismo problema, mientras continúa usando UIWebView en iOS7.

Lo mejor sería WKWebView un radar con Apple y cambiar a WKWebView mientras tanto.


Intenta actualizar a iOS 8.4.1. Funcionó para nosotros (sin embargo, no encontramos ninguna referencia a este error en las notas de la versión).


Resolví el problema. Tuve el mismo problema al agregar una etiqueta de video (la fuente era un archivo mp4 local de aproximadamente 18Mb). Pude identificar la etiqueta de video como responsable del bloqueo porque html sin video no falla. Luego intenté inyectar dos segundos después la etiqueta de video a través de javascript y la aplicación se bloqueó. Después de unas horas encontré esto: UIWebView cargando html5-Video EXC_BAD_ACCESS crash .

Mi solución fue extraer la inyección de etiquetas de video en una función javascript y llamar a esa función en webViewDidFinishLoad.

Entonces, en mi controlador tengo:

- (void)webViewDidFinishLoad:(UIWebView *)webView { [self.webView stringByEvaluatingJavaScriptFromString:@"placeVideoTag();"]; }

Mientras que en mi index.html tengo:

... <div id="left"> <div id="media-div"></div> ...

y (agregué una etiqueta de audio también):

<script> function placeVideoTag() { $(''#media-div'').html(''<video id="videoController" width="100%" controls > <source src="video_1.mp4" type="video/mp4"></video>''); $(''#media-div'').append(''<br/><audio id="audioController" controls="" width="100%"><source src="audio_1.mp3" type="audio/mp3"></audio>''); } </script>

Sé que suena como una solución extraña, pero realmente está funcionando. Tuve el mismo problema que el que se indica aquí, también habilitando el rastreo de zombies

Aleatoriamente, la aplicación se bloquea en WebThread con EXC_ARM_BREAKPOINT

Después de habilitar Zombie tracking en la consola, aparece este mensaje:

[UIViewAnimationState release]: mensaje enviado a la instancia desasignada 0x14deff70


Sé que llego tarde pero esto podría ayudar a alguien, asegúrese de que sus vistas de IBOutlet sean débiles. Esta respuesta me ayudó a deshacerme de este problema.


Si no está utilizando animaciones, puede evitar este error desactivando Animaciones. Ponga esto en su controlador método de inicio:

[UIView setAnimationsEnabled:NO];


asegúrese de establecer el delegado UIWebView en nil en el método dealloc

- (void)dealloc { [self.webView stopLoading]; self.webView.delegate = nil; }


[super viewDidLoad]; [[MPVolumeView alloc] init]; <------ add this line, that will be ok too. NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.amazon.com"]]; self.webView.layer.cornerRadius = 0; self.webView.userInteractionEnabled = YES; self.webView.multipleTouchEnabled = YES; self.webView.backgroundColor = [UIColor clearColor]; self.webView.scrollView.scrollEnabled = NO; self.webView.scrollView.bounces = NO; [self.webView loadRequest:urlRequest];