我的应用程序允许您长按某个项目,然后选择删除作为选项。当您按下删除时,会弹出一个警告视图,并要求您确认是否要删除它。当我选择是时它会删除两个项目,而不只是一个。使用断点我知道它会循环遍历该方法多次。两次准确
这是代码
- (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];
}
那我该如何修复呢?为什么要调用它两次而不是一次?