现象:当删除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. WiFiDog 与 AuthServer

    背景 在一些公共场所(比如公交车.地跌.机场等)连接当地的 WiFi 时会弹出一个验证表单,输入验证信息(比如短信验证码)后就能够通过该 WiFi 联网. 本文将介绍通过 OpenWrt WiFiDo ...

  2. 水库抽样Reservoir Sampling(蓄水池问题)

      知识复习 空间亚线性算法:由于大数据算法中涉及到的数据是海量的,数据难以放入内存计算,所以一种常用的处理办法是不对全部数据进行计算,而只向内存里放入小部分数据,仅使用内存中的小部分数据,就可以得到 ...

  3. Wasserstein GAN最新进展:从weight clipping到gradient penalty,更加先进的Lipschitz限制手法

    前段时间,Wasserstein GAN以其精巧的理论分析.简单至极的算法实现.出色的实验效果,在GAN研究圈内掀起了一阵热潮(对WGAN不熟悉的读者,可以参考我之前写的介绍文章:令人拍案叫绝的Was ...

  4. Android解析WindowManager(二)Window的属性

    前言 在上一篇文章我们学习了WindowManager体系,了解了Window和WindowManager之间的关系,这一篇我们接着来学习Window的属性. 1.概述 上一篇文章中我们讲过了Wind ...

  5. sql server 查询分析器中表名无效,有红线,其实是这张表的

    ctrl+shift+R 就OK了,就是刷新本地缓存.

  6. Linux Kernel 4.11首个候选版本开放下载

    Linus Torvalds宣布了即将到来的Linux Kernel 4.11内核分支的首个候选(RC)版本,用户可下载.编译并在自己的GNU/Linux发行版本中进行测试.Linus Torvald ...

  7. Git分布式工作流程

    Git官网给出了三种分布式工作流程: 集中式工作流程 集成管理者工作流 司令官与副官工作流 这里以私有gitserver服务器上的git-test项目为例,简单说明集中式工作流程. 基于分支的开发策略 ...

  8. centos编译安装php7

    环境说明 VMware 12 中搭建的CentOS 7 x64 4核 2G内存 环境中已经安装了http://blog.csdn.net/u014595668/article/details/5016 ...

  9. Linux中如何安装loadgenerator

    /* 1. 到官方网站到HP官网下载Load Generator 安装文件 _Load_Generator_11.00_T7330-15010.iso或者其它网站下载loadrunner-11-loa ...

  10. 如何在Code First、Database First和Model First之间选择

    Code First.Database First和Model First基本图解: 1)Database First: 如果数据库已经存在,可以使用VS自动生成数据模型,已经相关的edmx信息 2) ...