zoukankan      html  css  js  c++  java
  • cell_滑动

    /*
    //iOS_11.0
    -(UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath{
        
        __weak typeof(self) weakSelf = self;
        
        __block ZLJInventDataItem *inventModel = self.inventArray[indexPath.row];
        UIContextualAction    *other;
        //禁用状态
        if (inventModel.useState == 1) {
            //需要使用启用功能
            other = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                            title:@"启用"
                                                          handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                              [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                                 type:@"0"
                                                                                            startTime:inventModel.startTime 
                                                                                            doSuccess:^(BOOL success) {
                                                                                                
                                                                                                if (success) {
                                                                                                    inventModel.useState = 0;
                                                                                                    [weakSelf.recordTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                                                                                                }
                                                                                            }];
                                                              completionHandler(NO);
                                                          }];
            
        }else if(inventModel.useState == 0){//启用状态
            //需要使用禁用功能
            other = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                            title:@"禁用"
                                                          handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                              [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                                 type:@"1"
                                                                                            startTime:inventModel.startTime 
                                                                                            doSuccess:^(BOOL success) {
                                                                                                
                                                                                                if (success) {
                                                                                                    inventModel.useState = 1;
                                                                                                    [weakSelf.recordTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                                                                                                }
                                                                                            }];
                                                              completionHandler(NO);
                                                          }];
        }
        UIContextualAction    *delete = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                                                title:@"删除"
                                                                              handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                                                  [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                                                     type:@"2"
                                                                                                                startTime:inventModel.startTime 
                                                                                                                doSuccess:^(BOOL success) {
                                                                                                                    if (success) {
                                                                                                                        [weakSelf.inventArray removeObjectAtIndex:indexPath.row];
                                                                                                                        [weakSelf.recordTableView reloadData];
                                                                                                                    }
                                                                                                                }];
                                                                                  completionHandler(NO);
                                                                              }];
        
        other.backgroundColor = [UIColor lightGrayColor];
        UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[delete,other]];
        actions.performsFirstActionWithFullSwipe = NO;
        return actions;
    }
    */
    //iOS_8.0
    -(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
        
        
        UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal 
                                                                             title:@"删除" 
                                                                           handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
            
        
                                                                           }];
        rowAction.backgroundColor = [UIColor redColor];
        UITableViewRowAction *rowaction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal 
                                                                             title:@"禁用" 
                                                                           handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
            
                                                                           }];
        rowaction.backgroundColor = [UIColor grayColor];
        NSArray *arr = @[rowAction,rowaction];
        return arr;
    }
  • 相关阅读:
    RSA 与 DSA
    atlassian
    Cygwin
    windows下编写的Shell脚本在Linux下运行错误的解决方法
    NSKeyValueObserving(KVO)
    UIBezierPath 的使用介绍
    Objective
    Objective-C 内存管理原则
    Mac OSX 快捷键&命令行总览
    浅析Objective-C字面量
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/9927958.html
Copyright © 2011-2022 走看看