collectionview

iOS应用千万级架构:MVVM框架

大城市里の小女人 提交于 2020-10-02 10:54:50
业务模块内的MVC和MVVM架构 目前,唯品会中MVC和MVVM架构并存,后期会偏重于MVVM架构的使用。 MVC架构 Model :程序中要操纵的实际对象的抽象,为Controller提供经过抽象的业务数据,供Controller调度 View :视图,负责界面的元素的展示 Controller :控制器,管理View的声明周期及子view的生成和组装,负责Model和View之间的通信。 MVC框架的优势: 1. 应用广泛,几乎所有前端语言都有类似MVC的设计痕迹 2. 设计思想非常简洁,学习成本很低,新人上手非常容易。 MVC框架的问题: MVC并没有对数据请求和处理逻辑代码应该放在哪一层做出明确地划分,因此一旦页面逻辑或交互稍微复杂,Controller就会变得很臃肿,代码也就越来越难维护。 MVVM架构 MVVM框架是在MVC的基础上演化而来,MVVM想要解决的问题是尽可能地减少Controller的任务。 Model :程序中要操纵的实际对象的抽象 View(ViewController) :MVVM中的View不再是UIView的子类,而变成了UIViewController的子类。这里的View实际上就是MVC中剥离了处理呈现View逻辑部分的Controller,因此它仍然有各种UIView的属性,仍然有ViewController的声明周期的各种方法

【iOS】解决UICollectionView中使用reloadItemsAtIndexPaths进行局部cell更新导致视图重叠问题

a 夏天 提交于 2020-08-18 06:52:31
  UICollectionView与UITableView类似,都可以使用reloadData来进行cell内容的更新。   UICollectionView可以采用reloadItemsAtIndexPaths方法。 self.collectionView.reloadItems(at: [indexPath])   传入参数就是要刷新的cell所在的indexPath组成的数组。   但,reloadItemsAtIndexPath默认会有一个动画的过程,cell内容更新的瞬间会出现原内容与新内容重叠的情况。那么使用如下方式取消该动画即可: UIView.performWithoutAnimation { self.collectionView.reloadItems(at: [indexPath]) }   而使用reloadData进行全部cell的更新,则没有这个默认的动画过程。 来源: oschina 链接: https://my.oschina.net/u/4386991/blog/4306368

直播卖货小程序源码中,商品分类页面是如何实现的

耗尽温柔 提交于 2020-08-04 22:33:35
在直播卖货小程序源码中,一般都包含商品分类页面,如下图,那么这个页面是如何通过代码实现的呢?下面,小编以iOS版本的开发过程为例,来讲述下实现过程。 左边一级分类使用tableview来展示,右边的耳机分类使用collectionview来展示,主要就是实现一二级分类的联动。下面主要讲下点击和滑动。 1、左侧一级分类的点击实现 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.row != selectTableIndex) { //判断滑动是不是因为点击一级分类引起 isClickLeft = YES; selectTableIndex = indexPath.row; [tableView reloadData]; //二级分类滑动到对应的区域 [_classCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:selectTableIndex] atScrollPosition

iOS CollectionView 的那些事

有些话、适合烂在心里 提交于 2020-03-02 19:28:30
UICollectionView是开发中用的比较多的一个控件,本文记录UICollectionView在开发中常用的方法总结,包括使用 UICollectionViewFlowLayout 实现Grid布局、添加Header/Footer、自定义layout布局、UICollectionView的其它方面比如添加Cell的点击效果等等 本文Demo: CollectionViewDemo UICollectionView重要的概念 UICollectionView 中有几个重要的概念,理解这几个重要的概念对于使用 UICollectionView 有很大的帮助,这个几个概念从 用户的数据 、 布局展示的数据 、 视图展示的View 、 UICollectionView 充当的角色 这几个维度来展开讲解,这部分讲解的是偏概念的东西,如果你是一个实用主义者,那么可以直接跳到下一部分“UICollectionView和UICollectionViewFlowLayout”查看UICollectionView的简单实用,然后再回过头来回顾下这些概念,这样也是一个比较好的方式 用户的数据 用户的数据是UICollectionView中的DataSource,DataSource告诉UICollectionView有几个section、每个section中有几个元素需要展示

Java Map在遍历过程中删除元素

不想你离开。 提交于 2020-02-29 01:44:00
map遍历判断筛选删除时 如果对map使用put、remove或clear方法(例如map.remove直接删除),那么迭代器就不再合法(并且在其后使用该迭代器将会有ConcurrentModificationException异常被抛出). 当Iterator.remove方法导致map发生变化时,他会更新cursor来同步这一变化。 参见jdk文档描述: The iterators returned by all of this class's "collection view methods" are fail-fast: if the map is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove method, the iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic

Memory is not released during perform batch updates in CollectionView

£可爱£侵袭症+ 提交于 2020-01-25 09:06:01
问题 I've been working on a project of using two UICollectionView 's I have on that is the MainViewController with full screen cells that scroll horizontally and one that sits on that full screen cell and scrolls vertically. I have a functionality that adds as well as deletes cells. When a user taps and one of the pages of the MainViewController is deleted using the code below the memory that grew as cells were added is still being retained. Is there something Im doing wrong. All of my delegates