簡體   English   中英

uiactionsheet崩潰

[英]The uiactionsheet crash

我有一個工作表,如下所示:

- (void)Method1 {
    UIActionSheet *photoSourceSheet=[[UIActionSheet alloc]
                                     initWithTitle:@"Options"
                                     delegate:self
                                     cancelButtonTitle:@"Exit"
                                     destructiveButtonTitle:nil
                                     otherButtonTitles:@"opt1",@"opt2", @"opt3", nil];
    photoSourceSheet.tag=1;
    photoSourceSheet.delegate=self;
    [photoSourceSheet showInView:self.view];
}

- (void)Method2 {
    UIActionSheet *photoSourceSheet1=[[UIActionSheet alloc]
                                      initWithTitle:@"Select Video"
                                      delegate:self
                                      cancelButtonTitle:@"Cancel"
                                      destructiveButtonTitle:nil
                                      otherButtonTitles:@"Take New Video", @"Choose Existing Video", nil];
    //   photoSourceSheet.delegate=self;
    photoSourceSheet1.tag=2;
    photoSourceSheet1.delegate=self;
    [photoSourceSheet1 showInView:self.view];
}

在我的代表中,我有:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex: NSInteger)buttonIndex {
    if (actionSheet.tag==1) {
        if (buttonindex==2) {
            [self method2];
        }
    } else if (actionSheet.tag==2) {
        // some code
    }
}

我的委托方法被調用用於第一個操作表,即photoSourceSheet,但未調用photoSourceSheet1。 我需要做些特別的事情,例如手動解開紙嗎? 我的第二個UIActionSheet (photoSourceSheet1)出現了,但是一旦我在工作表上選擇一個選項,它就會使應用程序崩潰。 拋出EXEC_BAD_ACCESS

上面的代碼沒有錯。 EXEC_BAD_ACCESS基本上是由於內存管理不良所致。有時您無意中刪除了正在使用的對象。 嘗試啟用Zombies,它將告訴您確切的問題區域。

步驟:轉到“編輯方案內存管理”,然后選中“ 啟用僵屍對象 ”選項

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM