您的位置:首页 > 其它

Xcode7 collectionView的编辑新特性

2015-10-20 14:04 281 查看
Xcode7更新后可以使用iOS9的系统,其中有一些新的特新,讲一下collectionView的移动过程.collectionView和tableView类似,但是以前并不具备移动功能.现在有了移动功能能更加方法的使用.

设置移动跟tableView的移动类似,只需要几个代理方法就可以实现.

demo在这里(免费的)http://download.csdn.net/detail/reikomiao/9196345

注意:前面的collectionView的基本设置,自定义cell就不赘述了,直接讲移动方法

1.打开编辑状态,下面表示全部都可以编辑

- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}


2.设置移动

- (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
[self.collectionView moveItemAtIndexPath:sourceIndexPath toIndexPath:destinationIndexPath];
//当有数据的时候别忘了刷新数据
[self.collectionView reloadData]
}


就这么简单就实现移动了.

移动的时候长按Item想拖哪拖哪.看图

原来是这样



移动一下



一定要是iOS9,Xcode7之前的根本打不出来这些方法.就酱紫,挺好玩的,我能自己拖一天.(:з」∠)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: