这两天做ios遇到一个UITableViewCell 数据重合的问题,原因:引起这个问题的主要原因是,重用cell。之前cell上的内容未被清空,而又增加新增内容所致。从网上查了一些解决方法,比如:

解决方案:在使用cell时,首先删除cell上的view,代码如下。

static NSString *identifier = @"Fanmeli";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
//cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}else{
// 删除cell中的子对象,刷新覆盖问题。
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];
}
}

除了以上方法还有就是不让cell去复用,当然这种方式尽量避免,上面的方案试了一下没有起作用,不过也给我我启发,既然是cell复用,内容没有清空,那就再清空一下再赋值

 if (cell == nil) {
cell = [[SystemNoticeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellTableIdentifier];
}else{
[cell clearCell ];
}

成功解决这种问题。

UITableViewCell 重合问题解决方法的更多相关文章

  1. win7中VS2010中安装CSS3.0问题解决方法

    win7中VS2010中安装CSS3.0问题解决方法   在安装Standards Update for VS2010 SP1后,VS2010中没有CSS3.0问题,以下是我的解决方法 1.首先去官网 ...

  2. win8安装SQL Server 2005问题解决方法

    win8安装SQL Server 2005问题解决方法 1.正常安装任一版本的SQL Server 2005(最好安装企业版). 2.安装到SqlServer服务的时候提示启动服务失败(提示重试的时候 ...

  3. WingIDE中文乱码问题解决方法

    WingIDE中文乱码问题解决方法 安装完WingIDE后,首次运行python脚本时,若脚本中含有UTF-8中文,在Debug I/O输出框中,全部变成了乱码. 这时其实我们设置下WingIDE的编 ...

  4. PHP mkdir()无写权限的问题解决方法

    这篇文章主要介绍了PHP mkdir()无写权限的问题解决方法,对umask做了详细解释以及mkdir()后没写权限的解决方法,需要的朋友可以参考下   使用mkdir创建文件夹时,发现这个函数有两个 ...

  5. 【转】asp.net Cookie值中文乱码问题解决方法

    来源:脚本之家.百度空间.网易博客 http://www.jb51.net/article/34055.htm http://hi.baidu.com/honfei http://tianminqia ...

  6. wampserver下打开phpMyAdmin出现403错误的问题解决方法

    图1 图2 wamp下打开phpMyAdmin出现403错误的问题解决方法安装完wamp后打开其下的phpMyAdmin也就是路径http://localhost/phpmyadmin/ 出现[图一] ...

  7. Spring3 报org.aopalliance.intercept.MethodInterceptor问题解决方法

    原文:Spring3 报org.aopalliance.intercept.MethodInterceptor问题解决方法 一 开发环境:JDK5+Spring3.0.5+Myeclipse6.6+T ...

  8. virtualbox共享文件夹无访问权限问题解决方法

    virtualbox共享文件夹无访问权限问题解决方法 早就困扰了,这次新装虚拟机又碰到了,记录下来. 这篇文章主要介绍了virtualbox共享文件夹无访问权限问题解决方法,造成这个问题的原因是不跟v ...

  9. nfs:server 172.168.1.22 not responding,still trying问题解决方法 平台为RealARM 210平台

    nfs:server 172.168.1.22 not responding,still trying问题解决方法 ,平台为RealARM 210平台. 这里的问题是在使用nfs挂载文件系统时遇到的, ...

随机推荐

  1. python(4) - 装饰器2

    接下来修改一下上一篇的login,将用户名传递给验证函数. def login(func): #接收一个函数作为参数 def inner(name): print("用户验证通过....&q ...

  2. linux -cp/mv

    cp 复制 -r文件夹 -f强制没有提示 mv 移动改名 mv test.py temp/test2.py移动(后面只加路径就是移动.路径+文件名就是移动+改名) 执行mv一般会执行  mv -i交互 ...

  3. [转]bat批处理实现TXT文本合并

    本文转自:http://quanhuaming.blog.163.com/blog/static/1405693672010210101124905/ 有朋友问是否有可以合并TXT文本文件的软件,于是 ...

  4. [改善Java代码]覆写equals方法时不要识别不出自己

    建议45: 覆写equals方法时不要识别不出自己 我们在写一个JavaBean时,经常会覆写equals方法,其目的是根据业务规则判断两个对象是否相等,比如我们写一个Person类,然后根据姓名判断 ...

  5. Delphi2009下编译提示“无法找到“Excel_TLB”

    这是没有安装Excel组件导致的,安装Excel组件的步骤是: 1.新建Package工程 2.在Office安装目录下找到文件XL5CHS32.OLB 我的Office版本是2007,XL5CHS3 ...

  6. Java Concurrency - 浅析 CyclicBarrier 的用法

    The Java concurrency API provides a synchronizing utility that allows the synchronization of two or ...

  7. Android之ORMLite实现数据持久化的简单使用

    Android中内置了sqlite,但是常用的开发语言java是面向对象的,而数据库是关系型的,二者之间的转化每次都很麻烦.(作为程序员,应该学会偷懒)而Java Web开发中有很多orm框架(其实我 ...

  8. 使用 EF Power Tool Code Frist 生成 Mysql 实体

    原文:使用 EF Power Tool Code Frist 生成 Mysql 实体 1,在要生成的项目上右键   2,   3,   4,   5,  生成后的效果     已知问题: 1,在Mys ...

  9. 禁用iOS9 App Transport Security(ATS)特性时不起作用

    iOS 9发布后,原来开发的iPad应用在iOS9下面测试时,协议使用的是HTTP,发送网络请求时,Console窗口输出: App Transport Security has blocked a ...

  10. String的几种初始化方法的区别

    参考了: java中String的两种初始化方法   String a; String aa = ""; String aaa = "123"; String ...