UICollectionViewController编辑
问题描述:
我可以使用self.navigationItem.leftBarButtonItem = self.editButtonItem;
按导航面板上的编辑按钮,使UITableViewController
处于可编辑状态。UICollectionViewController编辑
如何使这种行为为UICollectionViewController
?
答
解决方案:在编辑按钮触摸
我添加的按钮与删除图像提供给细胞, 然后在cellForItemAtIndexPath:
...
if (self.editing) {
cell.deleteButton.hidden = NO;
}else cell.deleteButton.hidden = YES;
...
刷新数据:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
_fetchedResultsController = nil;
[self.collectionView reloadData];
}
按钮触发删除方法:
- (IBAction)deleteTour:(UIButton *)sender{
NSIndexPath *indexPath = nil;
indexPath = [self.collectionView indexPathForItemAtPoint:[self.collectionView convertPoint:sender.center fromView:sender.superview]];
}