使用UICollectionView实现应用程序管理(删除图标 抖动效果)

本文介绍了如何在iOS中使用UICollectionView实现删除图标和细胞抖动效果。通过介绍两种注册方法、自定义cell和header/footerView,以及添加长按和动画效果,详细展示了功能的实现过程。同时,提到了在UICollectionViewController中与UITableView的区别,并提供了示例项目的下载链接。
摘要由CSDN通过智能技术生成

ios小白一枚,刚开始学习,所以对于很多理论上的东西研究的还不够,写文章仅仅是为了养成一个好的习惯,有问题可以直接指出,虚心接受,请勿喷….

一、简单介绍UICollectionView:

       UICollectionView是ios6.0之后才出来的一种控件,是对UITableView一种更好的用户(程序猿)体验。基于UICollectionView 我们可以实现更炫的效果。 需要支持3种协议:
(UICollectionViewDateSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout)前两种参考UITableView就可以了。后面一种是对UICollectionView的布局.不同于UITableView的,UICollectionViewCell必须提前注册,这样在缓存池里面找不到cell后就会直接用注册过的创建一个cell.下面介绍一下cell的两种注册方法,以及对应的一些重要的代理方法

1. 两种注册方法:
1.1 class注册:
[self.collectionView registerClass:[ZHCollectionViewCell class] forCellWithReuseIdentifier:@"ZHCollectionCell"];
1.2 Nib注册
//先获取一个nib对象
UINib *nib = [UINib nibWithNibName:@"ZHCollectionReusableView" bundle:[NSBundle mainBundle]];
[self.collectionView registerNib:nib forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footer"];
1.2 关键的代理方法
#pragma mark - UICollectionViewDateSource   数据源方法
//返回这个section个数据个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
//cell的创建
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
//返回footer/headerView
-dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;

#pragma mark - ZHCollectionReusableViewdelegate   header/footer代理方法
- (void)collectionReusableViewedidapplist:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值