iOS开发 怎么删除UICollectionView的cell
2016-04-29 · 百度知道合伙人官方认证企业
兄弟连教育
兄弟连教育成立于2006年,11年来专注IT职业教育,是国内专业的IT技术培训学校。2016年成功挂牌新三板(股票代码:839467)市值过亿。开设专注程序员培训专注php、Java、UI、云计算、Python、HTML5、
向TA提问
关注
展开全部
1创建数组要求NSMutableArray类型全局变量属性
注1:变数组容易实现增删操作命名:_dataArray
注2:按手势需要添加代理UIGestureRecognizerDelegate
2dataArray赋值或初始化图:
注:于式建议使用本身类型相同没_dataArray进行初始化需要删除数组Crash通使用二
3实现点击Cell插入新数据
1、找并写UICollectionView自身代理:didSelectItemAtIndexPath;
2、获取点击NSIndexPath;
3、NSIndexPath转换数组;
4、调用insertItemsAtIndexPaths插入数据
4实现按Cell删除数据
1、cellForItemAtIndexPath创建并初始化按手势;
2、设置按间1.0秒触发;
3、添加手势代理.delegate = self;
4、设置标识.view.tag = indexPath.row
5实现按Cell删除数据
1、实现手势监听事件handlelongPress:;
2、区手势作始触发结束触发操作选其实现否则调用两;
3、根据recognizer手势传递.view.tag值删除数组;
4、recognizer.view.tag转换NSIndexPath型再转换NSArray型;
5、调用deleteItemsAtIndexPaths删除数据
6 解决问题:
1、_dataArray使用直接赋值删除能导致程序崩溃;
2、删除调用deleteItemsAtIndexPaths崩溃;
3、使用手势获取数组标误超数组
注1:变数组容易实现增删操作命名:_dataArray
注2:按手势需要添加代理UIGestureRecognizerDelegate
2dataArray赋值或初始化图:
注:于式建议使用本身类型相同没_dataArray进行初始化需要删除数组Crash通使用二
3实现点击Cell插入新数据
1、找并写UICollectionView自身代理:didSelectItemAtIndexPath;
2、获取点击NSIndexPath;
3、NSIndexPath转换数组;
4、调用insertItemsAtIndexPaths插入数据
4实现按Cell删除数据
1、cellForItemAtIndexPath创建并初始化按手势;
2、设置按间1.0秒触发;
3、添加手势代理.delegate = self;
4、设置标识.view.tag = indexPath.row
5实现按Cell删除数据
1、实现手势监听事件handlelongPress:;
2、区手势作始触发结束触发操作选其实现否则调用两;
3、根据recognizer手势传递.view.tag值删除数组;
4、recognizer.view.tag转换NSIndexPath型再转换NSArray型;
5、调用deleteItemsAtIndexPaths删除数据
6 解决问题:
1、_dataArray使用直接赋值删除能导致程序崩溃;
2、删除调用deleteItemsAtIndexPaths崩溃;
3、使用手势获取数组标误超数组
2016-05-04 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
deleteItemsAtIndexPaths:
Deletes the items at the specified index paths.
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths
Parameters
indexPaths
An array of NSIndexPath objects, each of which contains a section index and item index for the item you want to delete from the collection view. This parameter must not be nil.
Discussion
Use this method to remove items from the collection view. You might do this when you remove the items from your data source object or in response to user interactions with the collection view. The collection view updates the layout of the remaining items to account for the deletions, animating the remaining items into position as needed.
You can also call this method from a block passed to the performBatchUpdates:completion: method when you want to animate multiple separate changes into place at the same time. See the description of that method for more information.
Availability
Available in iOS 6.0 and later.
Declared In
UICollectionView.h
collectionView自带有删除cell的方法
Deletes the items at the specified index paths.
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths
Parameters
indexPaths
An array of NSIndexPath objects, each of which contains a section index and item index for the item you want to delete from the collection view. This parameter must not be nil.
Discussion
Use this method to remove items from the collection view. You might do this when you remove the items from your data source object or in response to user interactions with the collection view. The collection view updates the layout of the remaining items to account for the deletions, animating the remaining items into position as needed.
You can also call this method from a block passed to the performBatchUpdates:completion: method when you want to animate multiple separate changes into place at the same time. See the description of that method for more information.
Availability
Available in iOS 6.0 and later.
Declared In
UICollectionView.h
collectionView自带有删除cell的方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询