现象:当删除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. MySQL5.5登陆

    通过cmd登陆 mysql -h localhost -P 3306 -u root -p123456 h后面跟的是域名或IP地址:大写的P后面跟的是端口号:u后面跟的是用户名:小写的p后面跟的是密码 ...

  2. 微服务架构之spring cloud hystrix&hystrix dashboard

    在前面介绍spring cloud feign中我们已经使用过hystrix,只是没有介绍,spring cloud hystrix在spring cloud中起到保护微服务的作用,不会让发生的异常无 ...

  3. activiti查询

    一  1.根据当前任务id获得当前任务对象  Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).s ...

  4. 菜单Menu(AS开发实战第四章学习笔记)

    4.5 菜单Menu Android的菜单主要分两种,一种是选项菜单OptionMenu,通过按菜单键或点击事件触发,另一种是上下文菜单ContextMenu,通过长按事件触发.页面的布局文件放在re ...

  5. Android沉浸式状态栏

    private void initWindows() { Window window = getWindow(); int color = getResources().getColor(androi ...

  6. 2.MySQL 数据类型

    MySQL 数据类型 MySQL中定义数据字段的类型对你数据库的优化是非常重要的. MySQL支持多种类型,大致可以分为三类:数值.日期/时间和字符串(字符)类型. 数值类型 MySQL支持所有标准S ...

  7. Sentinel配置及部署

    一.sentinel.conf  port 26379 dir /opt/redis-3.0.7/dataSentinel sentinel monitor mymaster 192.168.1.15 ...

  8. Azure 中快速搭建 FTPS 服务

    FTP,FTPS 与 SFTP 的区别 FTP (File Transfer Protocol)是一种常用的文件传输协议,在日常工作中被广泛应用.不过,FTP 协议使用明文传输.如果文件传输发生在公网 ...

  9. Python学习---抽屉框架分析[小评论分析]0315

    注: 此处的小评论涉及数据库操作 初级小评论代码 settings.py INSTALLED_APPS = [ ... 'app01', # 注册app ] STATICFILES_DIRS = (o ...

  10. ZT A2DP协议笔记

    A2DP协议笔记 (2013-07-30 10:07:54) 转载▼ 标签: a2dp bluetooth src sink 分类: Bluetooth 1.概述     A2DP(Advanced ...