ios6 - UICollectionViewController 编辑

标签 ios6 uicollectionview

我可以使用 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]];
}

关于ios6 - UICollectionViewController 编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12567943/

相关文章:

iphone - Xcode - 本地化图像无法在设备上运行

ios - 如何在 UICollectionView 单元格中获得 1 像素宽度的边框? (提供代码)

ios - 如何在 Objective-C 中将带有补充 View 的标题添加到 UiCollectionView?

ios - 在 uicollectionview 底部添加加载指示器

iphone - XCode:新 iOS 6 ABAddressBook 函数出现 Apple Mach-O 链接器错误

iphone - iOS 6 : AVPlayerItem PresentationSize returning zero - (naturalSize method Deprecated on iOS 5)

iOS6 UIwebView CSS3D 转换没有硬件加速

objective-c - 在实例中使用connectiondidFinishLoading并将数据返回到另一个 View

iphone - deleteItemsAtIndexPaths 中的 UICollectionView 断言失败

ios - 如何获取位于 UICollectionView 中心的单元格的 indexPath