2010-04-26 53 views

回答

18

如果轉儲windows property的內容和所有視圖的所有子視圖,則可以看到UIAlertView位於覆蓋主窗口的單獨窗口中。在這裏我有一個帶有viewcontroller和tableview的導航欄(我刪除了它的子視圖,因爲它們不相關)。

<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>> 

這裏是生成轉儲的代碼。我發現它有時有用,看看是什麼東西時,沒有做什麼,我想到要去:

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

謝謝,我會看看。順便說一句,你是如何產生漂亮的格式化轉儲? – 2010-04-26 18:28:22

+1

這是個竅門。發現這個想法在 http://stackoverflow.com/questions/2528929/iphone-sdk-check-if-a-uialertview-is-showing - (BOOL)alertIsActive { \t的(一個UIWindow *窗口[UIApplication的sharedApplication] .windows){ \t \t如果([window.subviews計數]> 0) \t \t \t如果([[window.subviews objectAtIndex:0] isKindOfClass:[UIAlertView中類]]) \t \t \t \t返回YES; \t} \t return NO; } – 2010-04-27 13:36:58

+0

非常方便的片段 - 感謝分享@progrmr – Till 2011-11-24 00:02:00

4

活動的UIAlertView位於單獨的窗口(_UIAlertOverlayWindow)中。使用.windows property可以找到它。

整個UI在主線程中運行。

1

從你的窗戶和時間說明問題,聽起來像是你應該實現alertView:didDismissWithButtonIndex:。您可以在該方法中觸發後續代碼。

編輯:如果這沒有奏效,我會盡量延遲執行FB的東西,延遲後,當窗口真的保證不見了。

+0

好主意,但我已經嘗試過,問題依然存在,即使是動畫=否。 – 2010-04-26 18:24:30