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;
    }
  • 相关阅读:
    后缀自动机学习笔记
    [bzoj4516][Sdoi2016]生成魔咒——后缀自动机
    [bzoj1692][Usaco2007 Dec]队列变换——贪心+后缀数组
    BZOJ4811 [Ynoi2017]由乃的OJ
    codeforces796E Exam Cheating
    BZOJ1004 [HNOI2008]Cards
    BZOJ1798 [Ahoi2009]Seq 维护序列seq
    BZOJ4785 [Zjoi2017]树状数组
    UOJ207 共价大爷游长沙
    POJ3768 Katu Puzzle
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/9927958.html
Copyright © 2011-2022 走看看