Tag: uicollectionview

通过NSNotification从UICollectionView中删除单元格

我有一个简单的基于UICollectionView的应用程序 – 一个UICollectionView和一个基于NSMutableArray的数据模型。 我可以通过didSelectItemAtIndexPath:delegate方法删除没有问题的单元格: -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ [self.data removeObjectAtIndex:[indexPath row]]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; } 不过,我想通过UICollectionViewCell子类中的UICollectionViewCell通过UILongPressGestureRecognizer ,这一切都工作正常,我成功地触发NSNotification -(void)delete:(id)sender{ NSLog(@"Sending deleteme message"); [[NSNotificationCenter defaultCenter] postNotificationName:@"DeleteMe!" object:self userInfo:nil]; } 我在我的ViewController中捕获它,并调用以下方法: -(void)deleteCell:(NSNotification*)note{ MyCollectionViewCell *cell = [note object]; NSIndexPath *path = nil; if((path = [self.collectionView indexPathForCell:cell]) != nil){ [self.data removeObjectAtIndex:[path row]]; [self.collectionView deleteItemsAtIndexPaths:@[path]]; } } 它在deleteItemsAtIndexPaths:调用中崩溃 -[UICollectionViewUpdateItem action]: unrecognized selector […]

UICollectionView reloadData在节头中退出第一个响应者

我有一个UICollectionView有部分标题。 在部分标题中,我有一个UISearchBar 。 我想要在search栏中input我的collections夹视图中的内容。 我用下面的方法做到这一点: // The method to change the predicate of the FRC – (void)filterContentForSearchText:(NSString*)searchText { NSString *query = searchText; if (query && query.length) { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains[cd] %@ or createdAt contains[cd] %@ or noteText contains[cd] %@ or keywords contains[cd] %@", query, query, query, query]; [self.fetchedResultsController.fetchRequest setPredicate:predicate]; } else { […]

UICollectionView在水平滚动时捕捉到单元格

我知道以前有人问过这个问题,但是他们都是关于UITableViews或者UIScrollViews ,我无法得到可以接受的解决scheme。 我想要的是水平滚动我的UICollectionView时的捕捉效果 – 很像在iOS AppStore中发生的情况。 iOS 9+是我的目标构build,所以请在回答之前查看UIKit的变化。 谢谢。

UICollectionView,全宽单元格,允许自动布局dynamic高度?

这是关于当前iOS开发的一个相当基本的问题,我从来没有find一个好的答案。 在(说)垂直的UICollectionView , 是否可以有全angular单元格 ,但是允许dynamic高度由自动布局控制? (如果你是iOS新手“dynamic高度”,这意味着单元格有一些文本视图,可以是任何长度或图像可能是不同的大小,所以最终每个单元格是完全不同的高度。 如果这样怎么样? 这也许是“iOS中最重要的问题,没有很好的答案”。

如何交替基于行的UICollectiveViewCell的背景颜色?

我知道这是相当容易的UITableViewCells,但我不知道如何使用UICollectionView来解决这个问题。 编辑。 图片澄清。 单元格的文本内容在这里不一样,但应该是。 在风景中: 在肖像中: 我试图根据cellForItemAtIndexPath:方法中的索引path的行属性,将单元格的文本标签的颜色与单元格的背景颜色进行天真的切换。 但是索引path的行属性在UICollectionViewFlowLayout中并不是真正的行。

UIRefreshControl“拉起来”刷新?

如何将UIRefreshControl添加到UIColloectionView的底部? 这意味着它是如何工作的当滚动(查看旧数据或什么)?

当单元格仍然显示时,UICollectionView中的大单元格被移除

我有一个UICollectionView包含一些大的UICollectionViewCells。 这些单元格非常大,它们完全填充了UICollectionView边界并在屏幕之外延伸。 问题是从UICollectionView中删除大单元,并在仍然显示的时候排队等待重用,导致空白视图。 如果我继续在空白UICollectionView区域上滚动,最终单元格的最后部分出现,下一个单元格的开始就出现在正确的位置。 我已经有效地禁用了单元格重用,问题仍然存在,显然是因为UICollectionView认为单元格不再显示,因为没有angular落在集合视图的边界内。 为了演示一个集合视图是一个单栏,并有一个10000px高的单元格,滚动非常高的单元格时,它将在大约1000px的内容滚动离开屏幕后消失,并将重新出现以显示最终的1000px内容为细胞。 你可以下载一个简单的原型应用程序来显示这个问题: http : //jack.cox.s3.amazonaws.com/collectionviewprototype.zip

UICollectionView:页面控制的当前索引path

我正在使用stream布局的UICollectionView来显示单元格列表,我也有一个页面控件来指示当前页面,但似乎没有办法获得当前的索引path,我知道我可以得到可见的单元格: UICollectionView当前可见的单元格索引 但是可以有多个可见的单元格,即使我的每个单元格都占据了整个屏幕的宽度,如果将它滚动为两个单元格的两半,那么它们都是可见的,那么是否有办法只获取一个当前可见单元格的索引? 谢谢

如何在UICollectionView中更改滚动方向?

我在我的故事板的iOS应用程序中有一个UICollectionView 。 当设备处于纵向方向时,我希望它垂直滚动,当它在Landscaper中时,我希望它水平滚动。 在UICollectionView中,我可以看到scrollEnabled成员,但是我看不到设置滚动方向的方法。 我错过了什么吗?

UICollectionView estimatedItemSize – 最后一个单元格不alignment

我想通过单元格中的estimatedItemSize和preferredLayoutAttributesFittingAttributes来制作一个通常的horizo​​ntalScrolling flowLayout UICollectionView。 但是最后一个单元有问题。 任何想法在哪里是问题? 项目本身 @implementation RowCollectionView – (instancetype) initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout { if (self = [super initWithFrame:frame collectionViewLayout:layout]) { [self configureRowCollectionView]; } return self; } – (void) awakeFromNib { [super awakeFromNib]; [self configureRowCollectionView]; } – (void) configureRowCollectionView { self.backgroundColor = [UIColor lightGrayColor]; self.dataSource = self; self.delegate = self; // Horizontal Direction UICollectionViewFlowLayout *flowLayout […]