标签:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //取出模型 CarGroup * group = self.dataArray[indexPath.section]; carModel * model = group.cars[indexPath.row]; //初始化提示框; UIAlertController *alert = [UIAlertController alertControllerWithTitle:model.name message:@"修改成"preferredStyle: UIAlertControllerStyleAlert]; //alert View 添加文本输入框 [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { //textFiled的文本内容 textField.text = model.name; }]; //添加第二个文本 [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.text = group.title; }]; //添加确定按钮,附带监听操作 [alert addAction:[UIAlertAction actionWithTitle:@"确定修改" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { //点击按钮的响应事件; //取出数组中对应的textFiled UITextField * textField = alert.textFields.firstObject; //赋值 model.name = textField.text; //取出点击的cell的行号,和组号,点击了哪一个cell NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]; //刷新选中cell的数据,附带动画 [self.tabbleView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationTop]; }]]; //添加取消按钮 [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { //点击按钮的响应事件; }]]; //弹出提示框;点击后显示弹框 [self presentViewController:alert animated:true completion:nil]; }
标签:
原文地址:http://www.cnblogs.com/LDSmallCat/p/5082665.html