我可以通过按导航面板上的编辑按钮self.navigationItem.leftBarButtonItem = self.editButtonItem;
来进入可编辑状态。UITableViewController
如何做出这样的行为UICollectionViewController
?
我可以通过按导航面板上的编辑按钮self.navigationItem.leftBarButtonItem = self.editButtonItem;
来进入可编辑状态。UITableViewController
如何做出这样的行为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]];
}