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;
    }
  • 相关阅读:
    开发,从需求出发 &#183; 之四 春天在这里
    面向基于英特尔&#174; 架构的 Android* 的 CoCos2D
    js左右切换 选择年龄
    先序遍历创建二叉树,对二叉树统计叶子节点个数和统计深度(创建二叉树时#代表空树,序列不能有误)c语言
    [ACM] hdu 1251 统计难题 (字典树)
    设计模式:单例模式的三种创建方式及其各自的优缺点
    [Android 4.4.2] 泛泰A850 Mokee4.4.2 20140509 RC2.0 by syhost
    IA32 MMU paging初始化代码
    为Android开发人员定制的搜索引擎
    Android中Activity切换时共享视图元素的切换动画(5.0以上)
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/9927958.html
Copyright © 2011-2022 走看看