删除方法被调用太多次.为什么



我的应用程序允许你长按一个项目,然后选择删除作为一个选项。当您按下delete键时,会弹出一个警告视图,要求您确认是否要删除它。当我选择yes时,它会删除两个项目,而不是一个。使用断点,我知道它是循环通过该方法多次。准确地说是两次

代码

- (void)delete:(id)sender
{
MYSDynamicAlertView *alertView = [MYSDynamicAlertView new];
alertView.alertTitle = @"Are you sure you want to delete that?";
alertView.message = @"You won't be able to retrieve the message once its deleted.";
[alertView setTitle:@"Delete" dismissBlock:^{
    FCIMessageCell *cell               = self.cellShowingMenuController;
    NSIndexPath *ip                    = [self.tableView indexPathForCell:cell];
    FHChatInteraction *chatInteraction = self.visitor.chatInteractions[ip.row];
    [[FHSChatSocket sharedSocket] sendDeleteChatInteraction:chatInteraction];
    [chatInteraction destroy];    }
          direction:MYSDynamicAlertViewDirectionUp];
[alertView setTitle:@"Cancel" dismissBlock:^{
} direction:MYSDynamicAlertViewDirectionDown];

[alertView show];
}

那么我该如何解决这个问题呢?为什么它调用了两次,而不是一次?

MYSDynamicAlertView中有一个bug,导致块被调用两次。我刚刚修复了它,并提交了一个pull request。

同时你可以在这里找到修复的代码

相关内容

最新更新