Tag: uicollectionview

单元格中的单元格标签文本重叠

我正在尝试添加一个UILabel到我的collectionViewCell 。 但是,一些单元格文本开始与之前的单元格数据重叠之后。 更新 :这似乎只发生在我的手机(iphone 5),但不是在模拟器(2013年macbook空气)。 如这里所见: 我正在以编程方式实现整个视图。 这个问题似乎并没有与任何collectionview的元素,所以我会认为这个问题也适用于表视图。 我不确定我是否错过了以下几点: if(cell == nil) {// do something } 如果是这样的话,有人可以点亮一下这个function吗? 如果这不是问题,我真的不知道是什么原因造成的。 我也使用一个NSMutableAttributedString ,但是这不是问题,因为我试图插入一个普通的string,并得到相同的结果。 我的代码: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; TTSong *tempSong = [songArray objectAtIndex:indexPath.row]; UILabel *cellLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 110, 150, 40)]; [cellLabel setTextColor:[UIColor whiteColor]]; [cellLabel setBackgroundColor:[UIColor colorWithRed:0.0 […]

如何从自定义CollectionViewCell推动VC哪些是在TableViewCell上?

我有一个tableView和单元格,单元格上我有一个collectionView和显示它的一些内容。 我想发送一个selectindexPath的链接。 我想从TableViewCell上的Custom CollectionViewCell推送/呈现我的视图。 class secondTopicTableViewCell: UITableViewCell { @IBOutlet weak var relatedCustom: UICollectionView! var relArray = NSArray() func loadArray(arr: NSArray) { self.relArray = arr self.relatedCustom.reloadData() } } extension secondTopicTableViewCell : UICollectionViewDataSource { func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return relArray.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell […]

iOS UICollectionView:单元格不显示

我错过了一些明显的东西,因为这不是一件困难的事情。 我有故事板(其他视图)中的集合视图,原型单元格的重用标识为“单元格”,并在该单元格中具有100标签的UILabel。 代码(样板): – (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 4; } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; UILabel *label = (UILabel *)[cell viewWithTag:100]; label.text = @"Hello"; return cell; } 该代码在UICollectionViewController ,因为它应该。 当我运行,视图出现,但没有单元格或文本可见。 cellForItemAtIndexPath中的一个NSLog确认它被调用了4次。 我甚至改变了原型单元格的背景颜色,显示甚至没有出现单元格。 在viewDidLoad ,它调用: [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 我错过了什么?

collectionViewContentSize()与contentSize

有什么区别 collectionViewController.collectionViewLayout.collectionViewContentSize()和collectionViewController.collectionView.contentSize ? 你喜欢用什么?

如何在Scroll上设置UICollectionViewCell的大小,使其中间最大?

我有一个UICollectionView显示几行与一个全宽列(看起来像一个UITableView) 我想达到的是类似于这样的: …中间的细胞有更高的高度。 当用户向上和向下滚动时,中间单元格之前和之后的单元格animation回到给定单元格的默认高度。 有人可以概述我应该如何解决这个问题?

Collectionview performBatchUpdates崩溃

我正尝试添加新项目到我的集合视图使用insertItemsAtIndexPaths。 我的应用程序在performBatchupdate崩溃 – (void) addItems { NSArray *newProducts = @[@"1",@"2",@"3",@"4"]; [self.collectionView performBatchUpdates:^{ NSMutableArray *arrayWithIndexPaths = [NSMutableArray array]; for (NSInteger index = self.array.count; index < (self.array.count + newProducts.count); index++) { [arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:index inSection:0]]; } [self.array addObjectsFromArray:newProducts]; [self.collectionView insertItemsAtIndexPaths:arrayWithIndexPaths]; } completion:nil]; } 以下是崩溃日志: *断言失败 – [UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] 这个声明发生在单元没有注册到collectionview的时候。 我正在注册我的手机。

在iOS上紧密集合CollectionViewCells?

如果你想将细胞整齐地包装在一起,即使其他细胞中的某些内容更大,那又怎么样呢? 如果你看下面的图片,第一个string是最大的,但是如果我想把其他的单元格整齐地紧紧地捆在一起,不pipe大小如何,这是如何完成的? 无论从侧面还是从上到下,我都想做到这一点。 我希望细胞按照这幅图中箭头指向的方向排列。 更新:文本的第一行是两个单元格打包的togheter。

UIDocumentMenuViewController在iPad上崩溃,但不在iPhone上

演示一个UIDocumentMenuViewController ,以便能够将文件加载到应用程序中。 在iPhone上,它的作品,但不是在iPad上。 使用iOS9。 任何想法是什么错误? dmvc = UIDocumentMenuViewController(documentTypes: ["public.data"], inMode: .Import) dmvc!.delegate = self dmvc!.popoverPresentationController?.sourceView = addSongButton self.presentViewController(dmvc!, animated: true, completion: nil) 2016-06-07 09:45:45.256记住[2994:977408] UICollectionViewFlowLayout的行为没有定义,因为:2016-06-07 09:45:45.260记住[2994:977408]物品宽度必须小于UICollectionView的宽度减去左侧和右侧的值,减去内容左右值。 2016-06-07 09:45:45.261记住[2994:977408]相关的UICollectionViewFlowLayout实例是<_UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>,它被附加到; animation= {bounds.origin =; bounds.size =; 位置=; }; 层=; contentOffset:{0,0}; contentSize:{0,0}>集合视图布局:<_UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>。 2016-06-07 09:45:45.262记住[2994:977408]在UICollectionViewFlowLayoutBreakForInvalidSizes中创build一个符号断点,以在debugging器中捕获这个断点。 我不明白为什么错误消息引用collectionView ? 我根本不使用collectionView。 也许UIDocumentMenuViewController有它作为内部组件?

UICollectionViewCell旋转的alpha值

我有一个自定义UICollectionViewCell 。 我将UICollectionViewCell的alpha属性设置为0.0f ,以满足所有按预期工作的特定任务。 但是,当我旋转视图横向单元格的alpha重置为1.0 。 我玩过这个,集合视图保存选定单元格的状态,并删除单元格等,但不是单元格的alpha值。 我试图在didRotateFromInterfaceOrientation:上重新设置更改单元格的alpha值,但是一旦调用完成,它就会将其更改回1.0 。 我试图找出UICollectionViewCell的alpha值在旋转后重置自己的位置。 如果我运行下面的代码,我得到所需的alpha值为单元格,但在此之后的某些点,他们都改回到1.0 : – (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; //array containing IndexPaths for cells with 0.0f alpha value for (NSIndexPath *path in self.selectedlettersArray) { LetterCellView* lsv = (LetterCellView*) [self.collectionView cellForItemAtIndexPath:path]; lsv.alpha = 0.0f; } for (LetterCellView *lsv in self.collectionView.visibleCells) { NSLog(@"After Cell Alpha is : %f", lsv.alpha); […]

从UICollectionView的viewForSupplementaryElementOfKind获取NSFetchedResultsController节对象

我有一个名为Location的数据模型。 我在UICollectionViewController使用这些作为我的部分标题。 每个location都可以显示这些部分内的items 。 我想在viewForSupplementaryElementOfKind自定义我的部分标题。 但我不知道如何从这个方法recive正确的Location对象。 我曾尝试过这样的事情: -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections] [indexPath.section]; Item *item = sectionInfo.objects[0]; Location *location = item.location; SectionHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"SectionHeader" forIndexPath:indexPath]; headerView.label.text = location.name; […] 但我不断收到: Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 […]