例子:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

static NSString *CellIndentifier = @"Account";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
    
    //adjust the height for cell
    CGRect cellFrame = [cell frame];
    cellFrame.size.height = self.bgImageView.frame.size.height/2;
    
    //first time load the content
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier] autorelease];
    
    。。。。。。。。。

else

//这里主要是为了在滚动屏幕时候解决屏幕内容显示错误。但是却引发了这个问题,操作为向一个方向快速反复滚动就很容易crash,应该是reload后因为使用了dequeueReusableCellWithIdentifier导致table

无法得到正确的应当显示的cell内容和个数,导致出错。

[viewtable  reloadData];

解决方法:

static NSString *CellIndentifier = @"Account";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
    
    //adjust the height for cell
    CGRect cellFrame = [cell frame];
    cellFrame.size.height = self.bgImageView.frame.size.height/2;
    
    //first time load the content
    if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier] autorelease];
    
//创建所有的子视图

}else

{

//移除所有的子视图

while ([cell.contentView.subviews lastObject] != nil)
                {
                    [(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];
                }
//重新添加子视图

}

这样做的效果上看不会因为删除子视图然后出现空白等待加载的不良效果

UITableView 滚动时使用reloaddata出现 crash'-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (0)' Crash的更多相关文章

  1. UITableView 滚动时隐藏键盘

    #pragma mark - UItableView滚动时收键盘 - (void)scrollViewWillBeginDragging:(UITableView *)scrollView { [se ...

  2. UITableView 滚动流程性优化

    影响 UITableView 滚动的流畅性的原因 1. 在代理方法中做了过多的计算占用了 UI 线程的时间 2.同上 3.Cell 中 view 的组织复杂   关于第一点,首先要明白 tablevi ...

  3. 使用 jQuery Ajax 在页面滚动时从服务器加载数据

    简介 文本将演示怎么在滚动滚动条时从服务器端下载数据.用AJAX技术从服务器端加载数据有助于改善任何web应用的性能表现,因为在打开页面时,只有一屏的数据从服务器端加载了,需要更多的数据时,可以随着用 ...

  4. (原创)RecyclerView结合xUtils2.6实现滚动时不加载item,xUtils2.6的源码分析与改造

    我们知道xUtils中的bitmapUtils与listview相配合可以实现滚动时暂停加载 只需要一句话: listview.addOnScrollListener(new PauseOnScrol ...

  5. WOW.js – 在页面滚动时展现动感的元素动画效果

    在一些网页上,当你滚动页面的时候会看到各式各样的元素动画效果,非常动感.WOW.js 就是一款帮助你实现这种 CSS 动画效果的插件,很容易定制,你可以改变动画设置喜欢的风格.延迟.长度.偏移和迭代等 ...

  6. listview滚动时背景闪烁,背景黑或白问题解决

    android在使用listview时出现滚动时背景闪烁,变成背景黑或白的问题这样处理: 1:在布局文件中listview标签中加入: android:cacheColorHint="#00 ...

  7. EasyUI 1.4.4 DataGrid(大数据量) bufferview滚动时不加载下一页数据解决方案

    在使用Easyui DataGrid 过程中,发现若单页数据量超过300,IE浏览器加载速度很慢.也通过网上找寻了很多解决方案,最典型的就是去掉datagrid的自动列宽以及自动行高判断. 1.解决自 ...

  8. universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法

    在listview/gridview中使用UIL来display每个item的图片,当图片数量较多需要滑动滚动时会出现卡顿,而且加载过的图片再次上翻后依然会重复加载(显示设置好的加载中图片) 最近在使 ...

  9. css pre如果同时运用了css的border-radius、 overflow两个属性且标签中内容太多时,外部div滚动条在firefox下滚动时很卡

    pre如果同时运用了css的border-radius. overflow两个属性且标签中内容太多时,外部div滚动条在firefox下滚动时很卡. 解决方法:去掉css中border-radius. ...

随机推荐

  1. 水题:CF16C-Monitor

    Monitor 题目描述 Reca company makes monitors, the most popular of their models is AB999 with the screen ...

  2. 用Comparator排序和分组

    Test实体 import java.util.Objects; /** * @author gallen * @description * @date 2018/11/16 * @time 18:5 ...

  3. NPM包的安装及卸载

    NPM全名:node package manager,是node包管理工具,负责安装.卸载.更新等.新版的NodeJS已经集成了npm.所以装好NodeJS的同时,npm也已经装好了! 可以用cmd命 ...

  4. bootstrap 弹出框(Popover)插件 修改title等属性选项值

    <button type="button" class="btn btn-default ht-btn" data-toggle="popove ...

  5. day07 类的进阶,socket编程初识

    类的静态方法: 正常: 添加静态方法: 就会变成一个函数,不会自动传self 参数,不会调用类的变量和实例的变量  不在需要self 名义上归类管,但是它就是一个单独的函数,不在需要传入self,想怎 ...

  6. loj2021 「HNOI2017」大佬

    there #include <algorithm> #include <iostream> #include <cstring> #include <cst ...

  7. web前端开发小结

    1.浏览器内核 IE-----Trident Edge-----EdgeHTML Firefox-----Gecko Safari-----Webkit Chrome-----Blink(Webkit ...

  8. 记一次运行spark程序遇到的权限问题

    设置回滚点在本地运行时正常,在集群时就报错,后来是发现ceshi这个目录其他用户没有写的权限,修改其他用户的权限就好了 hdfs dfs - /ceshi

  9. 面试问题整理Andorid版本 date: 2017-1-12 21:14:36 categories: 技术

    Acitivty的四中启动模式与特点. standard:默认的启动模式 singleTop:适合那种接受通知启动的页面,比如新闻客户端之类的,可能会给你推送好几次 ,但是每次都是打开同一张页面调用o ...

  10. [java开发篇][代码规范]

    http://www.hawstein.com/posts/google-java-style.html Google Java编程风格指南 January 20, 2014 作者:Hawstein出 ...