现象:当删除CollectionView 当中的某个section的时候,报上面的错误

初步分析:当前CollectionView删除前后都不止一个Section,怎么会报那样的错误;猜想可能是相册界面的另外两个UICollectionView,对当前的CollectionView有影响。

初步验证:当加载了另外一个collectionView,再去删除原collectionView时并没有报错

解决方案:ViewDidLoad的时候加载三个CollectionView

再次分析:按道理应该是不会相互影响的,百度了一下之后发现通常出现这类问题是由于执行了增删操作之后,数据源返回的section数据和collectionView中的不一致, 检查代码numberOfSectionsInCollectionView 中 发现多了一个if(HasLoaded){  // do something; } else {  return 0; } 的判断;

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

    if (HasLoaded) {
NSInteger type =;
for (NSInteger k=; k<; k++) {
if (collectionView == self.collectionViewArray[k]) {
type = k;
break;
}
}
NSInteger count = self.httpConnect.WifiConnected? self.dataModel.ListsArray[type].SectionArray.count: self.dataModel.LocalListsArray[type].SectionArray.count;
if (count== && ![self.collectionViewArray[type] isHidden]) { self.noDataImageView.hidden = NO;
self.noDataLabel.hidden = NO;
}else {
self.noDataImageView.hidden = YES;
self.noDataLabel.hidden = YES;
}
return count;
}
else {
return ;
}
}

当我加载了其他两个CollectionView之后,使HasLoaded为true了,所以之前的分析只是凑巧解决了那个问题。

正确方案:去掉HasLoaded,即可

The number of sections contained in the collection view after the update (1) must be equal to the number of sections contained in the collection view before the update (0), plus or minus the number of的更多相关文章

  1. ZOJ Problem Set - 3329(概率DP)

    One Person Game Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge There is a very ...

  2. HDU5909 Tree Cutting(树形DP + FWT)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5909 Description Byteasar has a tree T with n ve ...

  3. Echars详解

    简介 ECharts,缩写来自Enterprise Charts,商业级数据图表,一个纯Javascript的图表库,可以流畅的运行在PC和移动设备上,兼容当前绝大部分浏览器(IE6/7/8/9 /1 ...

  4. 留念 C语言第一课简单的计算器制作

    留念 C语言第一课简单的计算器制作 学C语言这么久了.  /* 留念 C语言第一课简单的计算器制作 */   #include<stdio.h>  #include<stdlib.h ...

  5. CodeForces 558A

    Description Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coord ...

  6. Codeforces Round #312 (Div. 2) A. Lala Land and Apple Trees 暴力

    A. Lala Land and Apple Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/cont ...

  7. 【HDU 5909】 Tree Cutting (树形依赖型DP+点分治)

    Tree Cutting Problem Description Byteasar has a tree T with n vertices conveniently labeled with 1,2 ...

  8. zoj3329 One Person Game

    One Person Game Time Limit: 1 Second Memory Limit: 32768 KB Special Judge There is a very simple and ...

  9. ZOJ3329之经典概率DP

    One Person Game Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge There is a very ...

随机推荐

  1. ajax异步上传图片三种方案

    转自:http://www.jb51.net/article/51180.htm 注:自己尝试了前两种,都可用: 目前常用的异步文件上传功能有几种,比较多见的如使用iframe框架形式,ajax功能效 ...

  2. 为什么排版引擎解析 CSS 选择器时一定要从右往左解析?

    首先我们要看一下选择器的「解析」是在何时进行的. 主要参考这篇「 How browsers work」(http://taligarsiel.com/Projects/howbrowserswork1 ...

  3. LeetCode赛题390----Elimination Game

    # 390. Elimination Game There is a list of sorted integers from 1 to n. Starting from left to right, ...

  4. ASP.NET MVC学习笔记 第三天

    布局: 如果不使用布局页,需要将Layout属性设置为null. @{     Layout = null; } 使用默认布局页: 使用Add View对话框,选择使用布局页(是布局页的名称文本框为空 ...

  5. 网络测速 php代码

    <?php /*=====http://hi.csdn.net/yinyiniao=====*/ $fp=fopen("cs.txt","w"); for ...

  6. Ubuntu下搭建Hbase单机版并实现Java API访问

    工具:Ubuntu12.04 .Eclipse.Java.Hbase 1.在Ubuntu上安装Eclipse,可以在Ubuntu的软件中心直接安装,也可以通过命令安装,第一次安装失败了,又试了一次,开 ...

  7. angular based app开发流程

    整理user story mock UI,生成满足上述user story的原型界面 根据上述UI,整理出data model(适用于后端和angular的数据模型) 后端CRUD开发,形成REST ...

  8. 使用 docker-machine 管理 Azure 容器虚拟机

    安装 docker-machine 请参见该链接(https://docs.docker.com/machine/install-machine "https://docs.docker.c ...

  9. Python学习---DjangoForm的总结大全

    DjangoForm基础知识总结 1.Form是什么东西? 用于验证用户请求数据合法性的一个组件 2. Django的Form的实现步骤: a. 创建一个验证用户请求的模板 from django i ...

  10. composer随笔

    composer dump-autoload 生成autoload.php文件