我的应用程序允许您长按一个项目,然后选择删除作为一个选项。当您按下删除时,会弹出一个警告 View 并要求您确认是否要删除它。当我选择是时,它会删除两个项目,而不仅仅是一个。使用断点我知道它会多次循环执行该方法。准确地说是两次
这是代码
- (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
中存在一个错误,导致该 block 被调用两次。我刚刚修复它并提交了拉取请求。
在此期间,您可以找到固定代码 here .
关于ios - 删除方法被调用太多次。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24782282/