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

  • 相关阅读:
    设计模式-单列模式
    linux udp c/s
    linux 命令
    java String
    [转]Android进程间通信--消息机制及IPC机制实现
    Android入门:Activity四种启动模式
    CRT 重启Was
    jquery.cookie.js 使用
    div设置contentEditable="true"作为文本编辑器,定位光标解决办法
    居中展示图片
  • 原文地址:https://www.cnblogs.com/guozai9527/p/3817170.html
Copyright © 2011-2022 走看看