Tag: uicollectionview

你如何确定UICollectionView flowLayout中的单元格之间的间距

我有一个stream布局的UICollectionView,每个单元格是一个正方形。 我如何确定每行的每个单元格之间的间距? 我似乎无法find适当的设置。 我看到在集合视图的nib文件上有一个min间距属性,但是我把它设置为0,单元格甚至没有粘住。 任何其他的想法?

什么是'UIView-Encapsulated-Layout-Width'约束?

我一直在“无法同时满足约束”的例外(Xcode 5,iOS 7,设备和模拟器),列表中的约束之一是这样的: "<NSLayoutConstraint:0x165b23d0 'UIView-Encapsulated-Layout-Width' H:[StoryPlayerCell:0x165affc0(0)]>" 我没有自己设置这个约束。 这也不是一个NSAutoresizingMaskLayoutConstraint 。 但是它从哪里来? 我怎样才能摆脱它? 我不知道。 而且在Apple的文档中我找不到有关'UIView-Encapsulated-Layout-Width'的信息。 即使是Googlesearch也没有任何回报。 有什么build议么? PS:我在UICollectionView中使用UICollectionView的自定义子类中的这个单元格。 也许'Encapsulated-Layout'部分与此有关?

如何获得UICollectionViewCell的矩形?

UITableView有方法rectForRowAtIndexPath:但是在UICollectionView中不存在。 我正在寻找一个很好的干净的方式来抓住一个单元格的边界矩形,也许我可以添加一个UICollectionView类别。

UICollectionView只调用didSelectItemAtIndexPath如果用户双击,不会调用时,用户单击

我有一个关于屏幕大小的UICollectionView。 它显示的UICollectionViewCells与collectionView的大小相同。 每个单元格都有一个UIImage,它是单元格的大小。 CollectionView具有分页function,所以本质上它是一个全屏的照片幻灯片,用户可以滑过。 问题是这样的 -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath只在用户用手指敲击单元格或长按一个手指然后释放时才被调用。 它似乎没有单击select的默认行为。 我还没有对CollectionView手势识别器进行任何更改,因此无法find解决此问题的解决scheme。

用xib创buildUICollectionViewCell子类

我想创build一个UICollectionViewCell子类与链接一个xib,我有这样做:我已经创build一个新的xib文件,我已经添加一个UICollectionViewCell ,然后我创build了这个子类文件: @interface MyCell : UICollectionViewCell @property (weak, nonatomic) IBOutlet UILabel *label; @end 另外我已经在文件所有者自定义类中MyCell在界面生成器中的MyCell类,我已经添加了一个UILabel ,然后在我的UICollectionView viewDidLoad我这样做: [self.collectionView registerClass:[MyCell class] forCellWithReuseIdentifier:@"MyCell"]; UINib *cellNib = [UINib nibWithNibName:@"MyCell" bundle:nil]; [self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"MyCell"]; 以及在这个: – (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = (MyCell*)[cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath]; cell.label.text = @"Cell Text"; return cell; } 但是这不起作用,我收到这个错误: *** Terminating app due […]

UICollectionView更新单个单元格

我正在尝试更新UICollectionView的单个单元格,具体UICollectionView ,我只是试图更新由cell.imageView引爆的特定单元格中的图像。 [self.collectionView reloadData]不是一个真正的select,因为它使整个集合视图闪光。 [self.collectionView beginUpdates]不是[self.collectionView beginUpdates]的东西。 我知道我可以使用: [self.collectionView performBatchUpdates:^{ //do something } completion:nil]; 我不完全确定要在完成块中放置什么来更新某个单元格的imageView 。 这一切都是在didSelectItemAtIndexPath内部完成的。我也没有使用NSFetchedResultsController 。 有任何想法吗?

我怎么知道UICollectionView已经完全加载?

每当UICollectionView被完全加载时,我必须做一些操作,即当时所有的UICollectionView的数据源/布局方法都应该被调用。 我怎么知道? 有没有任何委托方法知道UICollectionView加载状态?

UICollectionReusableView方法没有被调用

我想我的UICollectionView部分有一个图像的标题。 我已经按照这些步骤: 在故事板上,为我的UICollectionView指定了一个头文件作为附件 给了它一个标识符 为它创build了一个UICollectionReusableView的子类 将自定义类分配给故事板上的类。 将一个ImageView放在标题附件中 在.h文件的自定义类中为ImageView了一个出口 在viewDidLoad实现以下viewDidLoad : [self.collectionView registerClass:[ScheduleHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier]; -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionReusableView *reusableview = nil; if (kind == UICollectionElementKindSectionHeader) { ScheduleHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier forIndexPath:indexPath]; headerView.headerImageView.image = [UIImage imageNamed:@"blah.png"]; reusableview = headerView; } return reusableview; } 我知道数据源和委托方法正在工作,因为我可以看到所有的单元格和它的部分。 但是,我没有我的标题。 我在上面的方法中放置了一个断点,它永远不会被调用。 我究竟做错了什么?

左alignmentUICollectionView中的单元格

我在我的项目中使用UICollectionView,在一行中有多个不同宽度的单元格。 根据: https : //developer.apple.com/library/content/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/UsingtheFlowLayout/UsingtheFlowLayout.html 它通过相同的填充在整个行上传播出单元格。 这发生的预期,除了我想左alignment他们,并硬编码填充宽度。 我想我需要inheritanceUICollectionViewFlowLayout,但是在阅读了一些教程等在线我似乎并没有得到如何工作。

iOS UICollectionView原型单元格大小属性被忽略

我使用两个原型单元格的UICollectionView。 原型单元格具有不同的宽度并包含不同的控件(图像视图和Web视图)。 我肯定会返回给定索引的正确原型单元格(所有单元格都显示正确的内容),但原型单元格大小将被忽略,而是使用集合视图的项目大小。 这不像我手动设置大小。 如果在实际显示时属性被忽略,那么允许原型单元在故事板中的大小是什么?