0

当我滑动并单击表格视图上的删除按钮时,我想要一个警报确认。基本上我想在发送数据之前显示一个带有“确定”和“取消”按钮的警报弹出窗口:

[[ConnectionSingleton getInstance] sendData:[NSString stringWithFormat:@"modifOrderFoodState::%@::%@::%@", [cellOrder objectForKey:@"orderFoodRelId"], state, [ConnectionSingleton getInstance].restaurantId] ];

如果客户端点击取消按钮,则中止发送数据功能。

这是我的代码:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

NSMutableDictionary *cellOrder = [orders objectAtIndex:indexPath.row];
NSString *state = @"4";

if (editingStyle == UITableViewCellEditingStyleDelete) {


    [[ConnectionSingleton getInstance] sendData:[NSString stringWithFormat:@"modifOrderFoodState::%@::%@::%@",
                                                 [cellOrder objectForKey:@"orderFoodRelId"],
                                                 state,
                                                 [ConnectionSingleton getInstance].restaurantId] ];
  }    
}

谢谢

4

1 回答 1

1

使此类成为 UIAlertViewDelegate。删除样式时创建 UIAlertView。将发送数据代码移动到 alertView:clickedButtonAtIndex: 方法中,如果用户单击 OK,则运行它。

于 2012-04-17T16:21:44.793 回答