2011-07-07 69 views
0

我剛剛添加了UIAlertView以確認下載操作。UIAlertView和UIActionView消失 - 應用程序處於不一致狀態

一旦用戶單擊確定,然後我調用一個方法(通過UIAlertView委託方法)以建立一個進度條UIActionSheet。 下載完成後,我關閉UIAlertView。

由於添加了UIAlertView,當UIActionSheet被取消時,我得到一個灰色的屏幕。 我無法點擊屏幕上的任何內容,但該應用似乎沒有崩潰(例如EXC_BAD_ACCESS)。

我唯一見過的類似於此(即屏幕變暗的地方)是當通知沒有被髮布在主線程(我在這裏做的)時。

有什麼建議嗎?

==== ==== UPDATE

//在我開始下載方法...

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm Your Download" message:[NSString stringWithFormat:@"Do you want to download this"] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Download", nil]; 
alert.tag = CONFIRM_DOWNLOAD; 
[alert show]; 

//然後,在UIAlertView中的委託方法...

- (void) alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (alertView.tag == CONFIRM_DOWNLOAD) { 
     if (buttonIndex == 0) { 
      DebugLog(@"Cancel download"); 
     } 
     else { 
      DebugLog(@"Download"); 

      [self startDownload]; 
     } 
    } 
} 
+0

請爲我們提供代碼。 – dasdom

回答

0

請參閱以下相關問題和接受的答案:

UIActionSheet from UIAlertView

基本上,你需要使用

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 

委託方法,而不是

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

方法。這允許alertView完全消除,而不是陷入中間狀態,您將看到部分變暗的封面視圖保留在哪裏。我並不確定,但它可能與將您的操作表附加到封面視圖之前有機會被刪除,而不是附加到您所瞄準的基礎視圖有關。

相關問題