当我滑动并点击桌面视图上的删除按钮时,我想要一个警报确认。 基本上我想在发送数据之前用“ok”和“cancel”按钮显示一个警告弹出窗口:
[[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] ];
}
}
由于
答案 0 :(得分:1)
将此类设为UIAlertViewDelegate。删除样式时创建UIAlertView。将发送数据代码移动到alertView:clickedButtonAtIndex:方法,并在用户单击“确定”时运行它。