我想在滑动并单击表格 View 上的删除按钮时收到警报确认。 基本上我想在发送数据之前显示一个带有“确定”和“取消”按钮的警报弹出窗口:
[[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] ];
}
}
谢谢
最佳答案
使此类成为 UIAlertViewDelegate。当样式删除时创建一个UIAlertView。将发送数据代码移动到alertView:clickedButtonAtIndex:方法中,并在用户单击“确定”时运行它。
关于objective-c - Tableview 上的删除警报确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10194896/