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

  • 相关阅读:
    服务器图片等资源在8080端口保存
    thinkphp 3.2.1 URL 大小写问题 下面有具体说明
    linux samba smb 在客户端无法连接使用
    php连接redis服务
    服务器死机 导致 mongo 挂掉
    同一个页面引用不同版本jquery库
    CSS3阴影 box-shadow的使用和技巧总结
    php 中使用正则
    Hbase-1.1.1-java API
    hive1.2.1问题集锦
  • 原文地址:https://www.cnblogs.com/guozai9527/p/3817170.html
Copyright © 2011-2022 走看看