只刷新cell不刷新section,这问题还难住了一阵子

需要用到:

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

注意:(NSArray *)indexPaths里面的下标要不同的哦,要是往最后插入,要记得看仔细哦

参考:http://blog.csdn.net/likendsl/article/details/17122505

//
//  ViewController.m
//  tableView
//
//  Created by apple on 15/8/6.
//  Copyright (c) 2015年 tqh. All rights reserved.
// #import "ViewController.h" @interface ViewController ()<UITableViewDataSource,UITableViewDelegate> {
    UITableView *tableview;
} @property (nonatomic,strong)NSMutableArray *dataSource; @end @implementation ViewController - (NSMutableArray *)dataSource {
    if (!_dataSource) {
        _dataSource = [[NSMutableArray alloc]initWithArray:@[@"",@"",@""]];
    }
    return _dataSource;
} - (void)viewDidLoad {
    [super viewDidLoad];
    tableview = [[UITableView alloc]initWithFrame:CGRectMake(, ,, )];
    tableview.dataSource = self;
    tableview.delegate = self;
    [tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellID"];
    [self.view addSubview:tableview];
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
    cell.textLabel.text = @"";
    return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableview beginUpdates];
    NSArray *array1 = [[NSArray alloc]initWithArray:self.dataSource];
    NSMutableArray *array = [[NSMutableArray alloc]init];
    for (int i = ; i < array1.count; i ++) {
        NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:i inSection:];
        [array addObject:indexPath_1];
    }
    array1 = [[NSArray alloc]init];
    [tableview beginUpdates];
    [tableview deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationLeft];
    [tableview endUpdates];
    
    //加载新数据
    self.dataSource = [[NSMutableArray alloc]initWithArray:@[@"",@"",@"",@"",@""]];
    NSArray *array2 = [[NSArray alloc]initWithArray:self.dataSource];
    NSMutableArray *array3 = [[NSMutableArray alloc]init];
    for (int i = ; i < array2.count; i ++) {
        NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:i inSection:];
        [array3 addObject:indexPath_1];
    }
    array2 = [[NSArray alloc]init];
    [tableview insertRowsAtIndexPaths:array3 withRowAnimation:UITableViewRowAnimationRight];
    [tableview endUpdates];
} @end

数据从3个变成5个了还带动画效果~~~~~~~

UITableView局部刷新的更多相关文章

  1. 两种局部刷新UITableView的方法的使用条件

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //1.取消选 ...

  2. UItableview section和cell的局部刷新

    局部刷新//一个section刷新    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];    [tableview reloadS ...

  3. iOS开发——UI进阶篇(四)tableView的全局刷新,局部刷新,左滑操作,左滑出现更多按钮,进入编辑模式,批量删除,自定义批量删除

    首先创建项目,在storyboard如下布局控件,设置好约束 然后创建cell模型类XMGWineCell数据模型类XMGWine创建UITableView,设置数据源协议,实现数据源方法懒加载数据这 ...

  4. UITableView的刷新

    UITableView的刷新1> 数据刷新的总体步骤* 修改模型数据* 刷新表格(刷新界面) 2> 刷新表格(刷新界面)的方法* 全局刷新(每一行都会重新刷新)- (void)reload ...

  5. (四十二)tableView的滑动编辑和刷新 -局部刷新和删除刷新 -待解决问题

    tableView的局部刷新有两个方法: 注意这个方法只能用于模型数据的行数不变,否则会出错. [self.tableView reloadRowsAtIndexPaths:<#(NSArray ...

  6. 安卓易学,爬坑不易——腾讯老司机的RecyclerView局部刷新爬坑之路

    针对手游的性能优化,腾讯WeTest平台的Cube工具提供了基本所有相关指标的检测,为手游进行最高效和准确的测试服务,不断改善玩家的体验.目前功能还在免费开放中. 点击地址:http://wetest ...

  7. MVC采用Jquery实现局部刷新

    该文纯粹属于个人学习,有不足之处请多多指教! 效果图: 单击Detail下面出现详细,效果如下: 为了使操作时两个不同的数据源相互干扰,使用局部视图刷新,代码如下: 首先介绍主页Index代码: @m ...

  8. ajax+php+mysql 实现点赞、局部刷新,每个IP只能对一篇文章点赞一次

    主要流程: 点赞—>判断当前设备IP是否对当前文章有过点赞记录—>若有记录,弹出提示“已经赞过了”; 若无记录,当前文章点赞数+1,并在记录设备IP点赞记录的表中插入信息. 文章表 art ...

  9. ASP.Net 在Update Panel局部刷新后 重新绑定JS方法

    我们知道Asp.Net中的Update Panel可以完成页面的局部刷新(实质上是Ajax),但是局部刷新完后,此区域的控件上所绑定的JS方法就会失效,因为我们用如下方法来重新绑定. var prm ...

随机推荐

  1. 《Prism 5.0源码走读》ModuleCatalog

    概念 ModuleCatalog 是Prism中主要概念之一,主要用来保存应用程序可用的modules(模块),每个module都是用ModuleInfo来定义(包含module的名称.类型和位置). ...

  2. C#巧用Excel模版变成把Table打印出来

    将一个做好的Excel模版,通过程序填上数据然后打印出来这个需求有两种方法一种是通过代码打开Excel模版然后填入数据然后再打印. 第二种方法就是我将要介绍的 1.将Excel设置好格式另存为HTML ...

  3. hdu 5224 Tom and paper

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5224 Tom and paper Description There is a piece of pa ...

  4. iOS项目开发中的目录结构

    目录结构: 1.AppDelegate   这个目录下放的是AppDelegate.h(.m)文件,是整个应用的入口文件,所以单独拿出来.   2.Models   这个目录下放一些与数据相关的Mod ...

  5. HTML5简略介绍

    今天要说下 HTML5特有的一个元素 canvas ,旨在让web页面上作矢量图不需要在依靠flash或是其他插件,在网页上使用canvas元素时,它会创建一块矩形区域,默认300*150,当然也是可 ...

  6. MVC 中的@Html.DropDownList下拉框的使用

    MVC 中的下拉框 实现方式,下面为大家介绍一个我自己认为比较好用的实现方式,而二话不说直接上代码: 第一步: 后台代码 //公共的方法 //在每次需要展示下拉框的时候,需要调用一下这个方法 [数据源 ...

  7. 深入浅出Spring(五) SpringMVC

    上一篇深入浅出Spring(四) Spring实例分析的博文中,咱们已经可以了解Spring框架的运行原理和实现过程,接下来咱们继续讲解Spring的一个延伸产品——Spring MVC 1.Spri ...

  8. Shade勒索病毒 中敲诈病毒解密 如 issbakev9_Data.MDF.id-A1E.f_tactics@aol.com.xtbl 解决方法

    [客户名称]:福建福州市某烘焙连锁企业 [软件名称]:思迅烘焙之星V9总部 [数据库版本]:MS SQL server 2000  [数据库大小]:4.94GB [问题描述]:由于客户服务器安全层薄弱 ...

  9. OGNL表达式介绍

    OGNL是Object-Graph Navigation Language的缩写,它是一种功能强大的表达式语言(Expression Language,简称为EL),通过它简单一致的表达式语法,可以存 ...

  10. 阴影 box-shadow(二)

    阴影 box-shadow(二) 1.阴影模糊半径与阴影扩展半径的区别 阴影模糊半径:此参数可选,其值只能是为正值,如果其值为0时,表示阴影不具有模糊效果,其值越大阴影的边缘就越模糊: 阴影扩展半径: ...