zoukankan      html  css  js  c++  java
  • 实现滑动出现删除按钮的代码

    // Override to support conditional editing of the table view.
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Return NO if you do not want the specified item to be editable.
    //    if (indexPath.section == 0) {
    //        return NO;
    //        [self isViewLoaded];
    //    }
        return YES;
    }
    
    #pragma mark - 以下几行代码实现删除
    
    // Override to support editing the table view.
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Delete the row from the data source
        [_favoriteArray removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
    
    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellEditingStyleDelete;
    }
    
    #pragma mark - 让删除按钮显示为中文
    
    - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
        return @"删除";
    }

    参考

    http://stackoverflow.com/questions/1168593/how-to-delete-a-row-of-a-table-in-iphone

    http://blog.csdn.net/a6472953/article/details/7530742 - 实现中文字"删除"

    http://www.cppblog.com/Khan/archive/2011/10/14/158305.html - 点击"删除"实现删除相应行

    https://github.com/yfujiki/YFJLeftSwipeDeleteTableView/blob/master/YFJLeftSwipeDeleteTableView/ViewController.m

  • 相关阅读:
    SQL中的聚合函数
    vs移动团队项目集合
    网页变量的赋值示例
    PRD、MRD、BRD的含义
    w3cschool中jQuery测试结果总结
    sql队伍的胜负情况
    winform中获取当前周次
    select2 的使用
    layui layer table 常见问题
    spring websocket tomcat was websphere9.0 Multiple Endpoints may not be deployed to the same path
  • 原文地址:https://www.cnblogs.com/guozai9527/p/3817170.html
Copyright © 2011-2022 走看看