Tag: uicollectionview

IOS的字母滚动为uicollectionview

我有一个collectionview显示人民和他们的名字的多个图像,我已经实现了search和sortingfunction,但问题是我也想按字母顺序排列。 但是它collectionview没有像表一样的委托方法。 – (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return[NSArray arrayWithObjects:@"a", @"e", @"i", @"m", @"p", nil]; } – (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { return <yourSectionIndexForTheSectionForSectionIndexTitle >; } 我也试过这个问题 ,但是这显示了一个部分中的collectionview单元格。 但问题是我不想要多个部分。 我只想要部分和实现字母滚动function,请指导我一些帮助 以上方法不在collectionviewlelegate方法中。

在UIScrollView中嵌套的UICollectionView之间的连续垂直滚动

虽然我知道嵌套的scrollView并不理想,但是我们的devise师为我提供了这个设置,所以我正在尽我所能使它工作。 让我们开始! 查看层次结构 的UIView UIScrollView (仅限垂直滚动) 的UIImageView UICollectionView#1(仅水平滚动) UIImageView(与以前的UIImageView不同) UICollectionView#2 (仅限垂直滚动) 重要的提示 我的所有视图都是使用程序化自动布局定义的。 UIScrollView子视图层次结构中的每个连续视图对其之前的视图具有y坐标依赖性。 问题 为了简单起见,让我们稍微修改一下术语: _outerScrollView将引用UIScrollView _innerScrollView将引用UICollectionView #2 我希望我的_innerScrollView在到达其contentSize底部时将其触摸事件路由到_innerScrollView 。 当我向后滚动时,我想要发生逆转。 目前,我有以下代码: – (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGFloat bottomEdge = [scrollView contentOffset].y + CGRectGetHeight(scrollView.frame); if (bottomEdge >= [_outerScrollView contentSize].height) { _outerScrollView.scrollEnabled = NO; _innerScrollView.scrollEnabled = YES; } else { _outerScrollView.scrollEnabled = YES; _innerScrollView.scrollEnabled = NO; […]

UICollectionView与多个子类UICollectionViewCell

我有我的UICollectionView按“datasetType”分组的多个部分。 我也有每个部分的自定义UICollectionViewCell。 我如何确定在cellForItemAtIndexPath方法中需要哪个自定义的cellForItemAtIndexPath ? 我的第一个虽然是基于[sectionInfo name] : id sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:indexPath.section]; if ([[sectionInfo name] isEqualToString:@"DatasetA"]) { DatasetACell *datasetACell = [collectionView dequeueReusableCellWithReuseIdentifier:datasetACellIdentifer forIndexPath:indexPath]; DatasetA *datasetA = [self.fetchedResultsController objectAtIndexPath:indexPath]; } 但我遇到了一个问题,试图加载错误的数据集单元格。 如果这个工作,我需要看看其他地方的错误? 还是我做这个部分是错的? 编辑: 我有什么应该工作。 问题是索引不排队。 对于我的fetchedResultsController,我创build它为: _fetchedResultsController = [Dataset MR_fetchAllSortedBy:NAME ascending:TRUE withPredicate:predicate groupBy:@"datasetType" delegate:self.fetchedResultsController.delegate inContext:[NSManagedObjectContext MR_contextForCurrentThread]]; 这会提取它们并按名称sorting。 我在项目中使用魔法logging,并使用其获取控制器,因为我无法让核心数据获取控制器工作: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; […]

UICollectionView在滚动中重新加载错误的图像

在下面的代码中,我从文本文件中下载图像URL,将其存储在NSMutableArray中,然后从CellforItemAtIndexPath中的这些URL中下载图像。 但是,当我上下滚动,短暂的一瞬间,错误的图像是在错误的地方。 它稍后纠正,但我想摆脱滚动的问题。 代码如下: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"Cell2"; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; AsyncImageView *recipeImageView = (AsyncImageView *)[cell viewWithTag:100]; UILabel *titleView = (UILabel *)[cell viewWithTag:101]; titleView.numberOfLines = 3; UIImageView *overlay = (UIImageView *)[cell viewWithTag:111]; FXBlurView *blurView = (FXBlurView *)[cell viewWithTag:110]; blurView.tintColor = [UIColor colorWithRed:51.0 green:51.0 blue:51.0 alpha:1]; […]

使用AutoLayout与Storyboard(不带XIB)的UICollectionViewCell的宽度和高度可变

以下是使用AutoLayout,UICollectionView和UICollectionViewCell的应用程序中的一个devise问题,该问题根据AutoLayout约束及其内容(某些文本)自动调整宽度和高度。 这是一个UITableView列表,每个单元格都有自己的宽度和高度,根据其内容分别针对每一行进行计算。 它更像是在应用程序(或WhatsUp)中构build的iOS消息。 很显然,应用程序应该使用func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize 。 问题是,在该方法,应用程序无法调用func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell也dequeueReusableCellWithReuseIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath!) -> AnyObject实例化单元格,填充特定的内容并计算其宽度和高度。 试图这样做会导致无限recursion调用或其他types的应用程序崩溃(至less在iOS 8.3中)。 解决这种情况的最接近的方法似乎是将单元格的定义复制到视图层次结构中,以使自动布局自动调整“单元格”(如单元格具有与父集合视图相同的宽度),所以应用程序可以configuration具有特定内容的单元格,计算其大小。 这肯定不是解决它的唯一方法,因为资源重复。 所有这一切都与设置UILabel.preferredMaxLayoutWidth到一些值应该是自动布局可控(非硬编码),可能取决于屏幕宽度和高度,或至less由自动布局约束定义设置,所以应用程序可以得到多行UILabel内在大小计算。 我不想从XIB文件中实例化单元格,因为Storyboards应该是当今的行业标准,而且我希望对代码有更less的干预。 编辑: 下面列出了不能运行的基本代码。 所以只有实例化variablescellProbe(未使用)崩溃的应用程序。 没有这个电话,应用程序运行顺利。 var onceToken: dispatch_once_t = 0 class ViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout { override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: […]

UICollectionView委托的抽头方法没有被调用

我有一个集合视图,数据源委托工作正常,但UICollectionViewDelegate : -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"didselect"); } 没有被调用,虽然我设置委托(因为我做了数据源,它的工作),我不得不提到,我的细胞是从一个笔尖加载,并连接到UICollectionViewCell的子类,无论如何,单元格不响应我的触摸。 我在我的单元格中的UIImageView中启用了用户交互。 还有: -(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"this is caled"); return YES; } 没有被调用! 正如我刚才提到的那样: [self.collectionView setDelegate:self]; 而且当然 <UICollectionViewDelegate> 我也没有任何touchBegan覆盖.. 更新 : 奇怪的! 如果我长时间按下,它只会被调用! 我怎样才能解决这个问题,我把delayedContentTouches设置为NO,而且我没有任何手势识别器。 请帮助。 谢谢。

刷新UICollectionView

有没有人知道如何重新加载/刷新UICollectionView集合视图正在显示? 基本上我正在寻找类似于UITableview的标准reloadData方法。

这个警告意味着什么:“设置集合视图的第一个响应者视图,但我们不知道它的types(单元格/页眉/页脚)”

我有一个UITollectionView与每个单元格中的UITextView。 当我点击其中一个文本视图,键盘出现时,我在输出面板中得到这个警告: setting the first responder view of the collection view but we don't know its type (cell/header/footer) 文本input工作正常,虽然。 不过,我真的很想知道在生产中使用此代码之前,这个警告的含义。

如何以编程方式启用/禁用UICollectionView中的节标题?

如何以编程方式启用/禁用UICollectionView中的节标题? 在Storyboard(checkbox)中可以很容易地完成,但是在代码中如何做呢?

创buildUICollectionViewCell时,子视图框架不正确

问题 我用自定义的UICollectionViewCell创build了一个UICollectionViewController。 自定义单元格包含一个大的矩形UIView(名为colorView)和一个UILabel(名为nameLabel)。 当该集合首先填充其单元格并打印colorView.frame时,打印的框架具有不正确的值。 我知道他们是不正确的,因为colorView框架比单元格框架本身大,即使colorView得到正确。 但是,如果我滚动collectionView足以触发以前创build的单元格的重用,colorView.frame现在具有正确的值! 我需要正确的框架,因为我想要应用圆angular到colorView图层,我需要正确的coloView大小,以便做到这一点。 顺便说一句,如果你想知道,colorView.bounds也有相同的错误大小值colorView.frame。 这个问题 为什么创build单元格时框架不正确? 现在有一些代码 这是我的UICollectionViewCell: class BugCollectionViewCell: UICollectionViewCell { @IBOutlet weak var colorView: UIView! @IBOutlet weak var nameLabel: UILabel! } 这是UICollectionViewController: import UIKit let reuseIdentifier = "Cell" let colors = [UIColor.redColor(), UIColor.blueColor(), UIColor.greenColor(), UIColor.purpleColor()] let labels = ["red", "blue", "green", "purple"] class BugCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout { override func […]