zoukankan      html  css  js  c++  java
  • IOS--常用控件--UITableView

    1.去除多余的空白单元格

    //去除多余的空白行

        UIView *view = [UIView new];

        view.backgroundColor = [UIColor clearColor];

        [tableView setTableFooterView:view];

        [view release];

    2.选中单元格后的反显颜色即刻消失

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        //[tableView deselectRowAtIndexPath:indexPath animated:YES];//选中后的反显颜色即刻消失


    }

    3.让tableView定位到最下边一行

        if ([self.array count]>1) {

            //让tableView定位到最下边一行

            NSIndexPath* indexPath = [NSIndexPath indexPathForRow:[self.array count]-1 inSection:0];

            [self.myTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];

        }

    4.tableview刷新指定行

    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:currentCommentId inSection:0];

    NSArray *array=[[NSArray alloc] initWithObjects:indexPath, nil];

    //tableview刷新指定行,指定的行数应该放到一个array中,提供给该方法

    [myTableView reloadRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationMiddle];

    5.定制选中单元格后的颜色

    UIView *cellSelectedBackview=[[UIView alloc] initWithFrame:cell.frame];

            cell.selectedBackgroundView=cellSelectedBackview;

            [cellSelectedBackview release];

            cell.selectedBackgroundView.backgroundColor=COLOR_WO_BACK;

    6.增加cell

     //先更新数据

     //更新ui(无需手动更新ui,insert会自动执行reloadData)

    NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:sender.tag];

                [self.myTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

    7.删除cell(利用动画,比较简单的方式)

          [CATransaction begin];

                    [CATransaction setCompletionBlock:^{

                        // animation has finished

                        [_myTableView reloadData];

                    }];

          // do some work

                    [_myTableView beginUpdates];

          //先更新数据

                    [_insurancePeopleArray removeObjectAtIndex:deleteIndex];

          //更新ui

                    NSIndexPath * indexPathOld = [NSIndexPath indexPathForRow:deleteIndex-10 inSection:0];

                    NSArray *array=[NSArray arrayWithObjects:indexPathOld, nil];

                    [self.myTableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];

                    [_myTableView endUpdates];

                    [CATransaction commit];

  • 相关阅读:
    Educational Codeforces Round 86 (Rated for Div. 2) D. Multiple Testcases
    Educational Codeforces Round 86 (Rated for Div. 2) C. Yet Another Counting Problem
    HDU
    HDU
    HDU
    HDU
    Good Bye 2019 C. Make Good (异或的使用)
    Educational Codeforces Round 78 (Rated for Div. 2) C. Berry Jam
    codeforces 909C. Python Indentation
    codeforces1054 C. Candies Distribution
  • 原文地址:https://www.cnblogs.com/howdoudo/p/4274925.html
Copyright © 2011-2022 走看看