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];

  • 相关阅读:
    day1-python简介+安装
    dgango中admin下添加搜索功能
    调用zabbix 分组api
    python 调用zabbix api实现查询主机信息,输出所有主机ip
    python实现用户登录界面
    怎样过滤跨站恶意脚本攻击(XSS)
    java服务安装(一):使用java service wrapper及maven打zip包
    详解Maven项目利用java service wrapper将Java程序生成Windows服务
    使用tomcat7-maven-plugin部署Web项目
    常用Maven插件介绍
  • 原文地址:https://www.cnblogs.com/howdoudo/p/4274925.html
Copyright © 2011-2022 走看看