【问题标题】:UICollectionViewController editUICollectionViewController 编辑
【发布时间】:2012-09-24 15:15:24
【问题描述】:

我可以通过按导航面板上的编辑按钮使用self.navigationItem.leftBarButtonItem = self.editButtonItem; 使UITableViewController 处于可编辑状态。

如何为UICollectionViewController做出这样的行为?

【问题讨论】:

    标签: ios6 uicollectionview


    【解决方案1】:

    解决方案:

    我在单元格中添加了带有删除图像的按钮, 然后在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]];
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-18
      • 1970-01-01
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      相关资源
      最近更新 更多