zoukankan      html  css  js  c++  java
  • 滑动cell 显示的按钮 类型分别是 删除 置顶 其他

    - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath

    {

            //删除按钮

            UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){

                    [_dataArray removeObjectAtIndex:indexPath.row];

                    [tableView deleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];

                }];

             

         

            //置顶按钮

            UITableViewRowAction *toTopRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){

                     

                    NSLog(@"置顶");

                     

                }];

            toTopRowAction.backgroundColor = [UIColor orangeColor];

             

            //其他按钮

            UITableViewRowAction *otherRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"其他" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath){

                    NSLog(@"其他");

                }];

         

            otherRowAction.backgroundColor = [UIColor lightGrayColor];

         

            //返回按钮数组

            return @[deleteRowAction, toTopRowAction, otherRowAction];

    }

    1
  • 相关阅读:
    [LeetCode] 811. Subdomain Visit Count
    [LeetCode] 993. Cousins in Binary Tree
    [LeetCode] 443. String Compression
    [LeetCode] 448. Find All Numbers Disappeared in an Array
    [LeetCode] 442. Find All Duplicates in an Array
    [LeetCode] 4. Median of Two Sorted Arrays
    [LeetCode] 983. Minimum Cost For Tickets
    [LeetCode] 322. Coin Change
    [LeetCode] 249. Group Shifted Strings
    [LeetCode] 1009. Complement of Base 10 Integer
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5776236.html
Copyright © 2011-2022 走看看