现象:当删除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. C# 求百分比并保留2位小数

    , b = ; decimal c = (decimal)a / b; , ); , )).ToString() + "%"; Console.WriteLine( - resul ...

  2. Android学习笔记(5)----启动 Theme.Dialog 主题的Activity时程序崩溃的解决办法

    新建了一个Android Studio工程,在MainActivity的主界面中添加了两个按钮,点击其中一个按钮用来启动 NormalActivity,点击另一按钮用来启动DialogActivity ...

  3. CMD命令行下编译.Net Visual Studio 项目

    有时候我们需要编译.net 的sln解决方案,可是VS打开的速度太慢,可以用命令行进行代替,详细过程如下: 1.开始菜单——>Visual Studio 2017(根据你电脑上安装的VS版本来) ...

  4. Java学习-1

    数组 运算符 包 访问权限 修饰符 数组 1. 数组的声明: int[] a; 2. 数组的创建 使用new运算符数组的创建int[] a = new int[100] 数组的长度不要求是常量:new ...

  5. Excel VBA开发

    一.Excel添加treeview控件 如果是以VBA中为窗体添加,菜单:工具->附加控件,从中选择“Microsoft TreeView Control”: 在控件工具箱中点击其它控件,从中选 ...

  6. java抽象类,接口与异常

    1.抽象类: 定义;包含一个抽象方法的类称称为抽象类,抽象类在class前使用adstract关键词修饰. 抽象方法;只声明未实现的方法称为抽象方法,使用adstract关键字声明该方法. 抽象类定义 ...

  7. Python学习---生成器的学习1210

    在Python中,这种一边循环一边计算的机制,称为生成器: 结论: 生成器本质是一个函数,不同于函数的是它生成的是一个对象,不执行函数内的代码 1.1. 列表生成器 列表生成器: 列表是直接生成数字在 ...

  8. Java学习---常见的模式

    Java的常见模式 适配器模式 package com.huawei; import java.io.BufferedReader; import java.io.IOException; impor ...

  9. ASP.NET Core 使用 SQLite 教程,EF SQLite教程,修改模型更新数据库,适合初学者看懂详细、简单教程

    SQLIte 操作方便,简单小巧,这里笔者就不再过多介绍,感兴趣可以到以下博文 https://blog.csdn.net/qq_31930499/article/details/80420246 文 ...

  10. SQL查询含有%号的字段

    select * from EMS_ANNOUNCEMENT where 1=1  and title like '%\%%'  escape '\'