zoukankan      html  css  js  c++  java
  • qq联系人 左滑删除功能

    // 局部刷新

        NSArray *indexPaths = @[

                                [NSIndexPath indexPathForRow:0 inSection:0],

                                [NSIndexPath indexPathForRow:1 inSection:0]

                                ];

        [self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationLeft];

     

     

    #pragma mark - 按钮的点击

     

    - (IBAction)remove {

     

        // 进入编辑模式

     

    //    self.tableView.editing = !self.tableView.isEditing;

     

        [self.tableView setEditing:!self.tableView.isEditing animated:YES];

     

    }

     

     

     

    #pragma mark - UITableViewDelegate

    /**

     *  只要实现这个方法,就拥有左滑删除功能

     *  点击左滑出现的Delete按钮 会调用这个

     */

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

    {

        NSLog(@"commitEditingStyle--");

        [self.wineArray removeObjectAtIndex:indexPath.row];

        [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];

    }

     

    /**

     *  修改默认Delete按钮的文字

     */

    //- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

    //{

    //    return @"删除";

    //}

     

    - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath

    {

    //    self.tableView.editing = YES;

        UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"关注" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

    //        [self.tableView reloadData];

    //        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];

            // 退出编辑模式

            self.tableView.editing = NO;

        }];

        

        UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

            

            [self.wineArray removeObjectAtIndex:indexPath.row];

            [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

            

        }];

        return @[action1,action];

    }

    @end

     

  • 相关阅读:
    SQL清除数据库日志方法
    TFS服务器及服务帐号迁域的处理
    about WBS
    ASP.NET URL Rewrite. URL重写
    查看SQL Server中某数据库下每个表占用的空间大小
    [西安招聘] 微软西安分公司 招聘.NET软件工程师,MOSS开发工程师
    企业微信的数据打通
    常见Post请求与实现
    Python解释器与__pycache__文件夹的生成
    微信开放平台OpenID与UnionID的区别
  • 原文地址:https://www.cnblogs.com/liuzhenjie/p/5451119.html
Copyright © 2011-2022 走看看