2010-04-26 1097 views

Respuesta

18

Si elimina los contenidos del windows property y todas las subvistas de todas las vistas, puede ver que el UIAlertView se encuentra en una ventana separada que se superpone a la ventana principal. Aquí tengo una barra de navegación con un viewcontroller y una tabla vista (eliminé sus subvistas porque no son relevantes).

<UIWindow: 0x411fd50; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x4120af0>> 
: <UILayoutContainerView: 0x4123310; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x411f800>> 
: | <UINavigationTransitionView: 0x4123500; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x41232e0>> 
: | : <UIViewControllerWrapperView: 0x4519d30; frame = (0 64; 320 416); autoresize = W+H; layer = <CALayer: 0x4519a40>> 
: | : | <UITableView: 0x7808000; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x45182a0>> 
: | <UINavigationBar: 0x45018b0; frame = (0 20; 320 44); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x4500fe0>> 
: | : <UINavigationItemView: 0x4522a20; frame = (100 8; 160 27); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4526310>> 
: | : <UINavigationItemButtonView: 0x45230a0; frame = (5 7; 87 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4520260>> 
<_UIAlertOverlayWindow: 0x4179b70; frame = (0 0; 320 480); opaque = NO; layer = <CALayer: 0x4188dc0>> 
: <UIAlertView: 0x4194bc0; frame = (3.8 161.95; 312.4 177.1); transform = [1.1, 0, 0, 1.1, 0, 0]; opaque = NO; animations = { transform=<CABasicAnimation: 0x4191160>; opacity=<CABasicAnimation: 0x41226f0>; }; layer = <CALayer: 0x4144c30>> 
: | <UILabel: 0x4177e70; frame = (12 15; 260 23); text = 'Name of Date'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4179370>> 
: | <UILabel: 0x418b100; frame = (12 45; 260 41); text = 'Name of the date that you...'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x4128450>> 
: | <UIThreePartButton: 0x41942a0; frame = (11 102; 262 43); opaque = NO; tag = 1; layer = <CALayer: 0x4191f30>> 

Aquí está el código que produce el volcado. He encontrado que es útil en ocasiones para ver lo que está pasando cuando algo no está haciendo lo que espero:

void dumpView(UIView* aView, NSString* indent) { 
    if (aView) { 
     NSLog(@"%@%@", indent, aView);  // dump this view 

     if (aView.subviews.count > 0) { 
      NSString* subIndent = [[NSString alloc] initWithFormat:@"%@%@", 
          indent, ([indent length]/2)%2==0 ? @"| " : @": "]; 
      for (UIView* aSubview in aView.subviews) dumpView(aSubview, subIndent); 
      [subIndent release]; 
     } 
    } 
} 

void dumpWindows() { 
    for (UIWindow* window in [UIApplication sharedApplication].windows) { 
     dumpView(window, @"dumpView: "); 
    } 
} 
+0

Gracias, voy a echar un vistazo. Por cierto, ¿cómo se produce el bonito volcado con formato? –

+1

Esto hace el truco. Encontrado en la idea http://stackoverflow.com/questions/2528929/iphone-sdk-check-if-a-uialertview-is-showing - (BOOL) alertIsActive { \t para (UIWindow * ventana de [UIApplication sharedApplication] .Windows) { \t \t si cuentan [window.subviews] (> 0) \t \t \t si ([[window.subviews objectAtIndex: 0] isKindOfClass: [UIAlertView clase]]) \t \t \t \t regresar SÍ; \t} \t return NO; } –

+0

Fragmento muy útil: gracias por compartir @progrmr – Till

4

El UIAlertView activo vive en una ventana separada (_UIAlertOverlayWindow). Use .windows property para encontrarlo.

Toda la interfaz de usuario se ejecuta en el hilo principal.

1

Desde el problema que usted describe con ventanas y el tiempo, suena como debe implementar alertView:didDismissWithButtonIndex:. Puede activar su código de seguimiento desde ese método.

EDITAR: si eso no funciona, intentaría hacer un retraso para ejecutar el material de FB después de un retraso cuando la ventana realmente está garantizada que se habrá ido.

+0

Buena idea, pero lo he intentado y el problema persiste, incluso con animated = NO. –

Cuestiones relacionadas