Tag: uicollectionview

iOS:重新加载UICollectionView的单个单元格

我正试图按照下面的post重新加载UICollectionView中的单元格: UICollectionView更新单个单元格 我知道我最终想要看起来像这样的东西: [self.collectionView reloadItemsAtIndexPaths:??]; 但我不知道如何find并传递特定单元格的indexPath。 任何人都可以提供任何指针? 我有一个NSMutableArray包含所有的单元格信息(在每个单元格中生成的imageViews)。 理想情况下,我想要做的是通过NSMutableArray的索引刷新页面上的相应单元格。 但我不知道如何将数字索引转换为索引path。 在此先感谢您的帮助!

可以在uitableviewcontroller或uicollectionviewcontroller中添加UIView(Admob)

我想添加admob在uitableviewcontroller或uicollectionviewcontroller在屏幕的底部。 所以为此,我必须在uitableview控制器或uicolleectionview控制器的底部添加uiView(GAD BannerView)。 那我该怎么做呢? 其实我们可以在uiviewcontroller中轻松的添加uiview,但是我怎样才能在uitableviewcontroller或者uicollectionviewcontroller中添加这个呢?

由于“UICollectionViewLayoutAttributes”而导致集合查看单元格删除时崩溃

我的数据源是一个二维数组,因为我将emojis分成了多个小节。 eg. [[a,b,c,d],[e,f,g],[h,j,k,l,m]] 我的单元格删除代码 – func deleteEmoji(at indexPath: IndexPath) { // Get the bad emoji let emojiToBeDeleted = emojisArray[indexPath.section][indexPath.row] // Delete the emoji from datasource and collection view emojisArray[indexPath.section].remove(at: indexPath.row) stickerCollectionView.deleteItems(at: [indexPath]) // Delete the section from datasource and collection view as its emoji count is zero if emojisArray[indexPath.section].count == 0 { emojisArray.remove(at: indexPath.section) stickerCollectionView.deleteSections(IndexSet(integer: […]

没有UICollectionViewLayoutAttributes实例为-layoutAttributesForSupplementaryElementOfKind:

标题是我得到的错误,我不知道为什么,但这里有一些信息,所以希望有人在这里可以澄清我。 我已经分类了UICollectionViewFlowLayout因为这节省了我在UICollectionViewFlowLayout为单元格自己计算框架(也许这是一个问题?)。 然后,我使用UICollectionViewLayoutAttributes信息来计算一个补充的视图,放置它,我得到我想要的布局。 我使用performBatchUpdates:completion:添加,删除和更新视图。 插入工作正常,但是删除项目出现在标题中显示的错误。 所以我知道为什么错误发生,但我不知道为什么它应该发生 。 用一个例子来说明导致这个问题的场景 从1个项目开始,1个补充视图1个部分 添加两个项目( prepareLayout看3个项目与3补充意见) 删除项目( prepareLayout看到2个视图和2个补充视图) layoutAttributesForSupplementaryViewOfKind:atIndexPath:被调用时要求索引path的属性与部分:0和项目:2 崩溃,因为它要求第三个补充视图的属性,即使早些时候它叫做准备布局设置2个项目和2个补充视图 举手投降,绝望 所以,我所知道的有问题的function是: – (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath { return self.layoutInfo[elementKind][indexPath]; } 这当然是由UICollectionView的内部networking自动调用,所以我不知道为什么它要求在该索引path的补充视图。 任何人有任何想法? 也许这是我如何使用performBatchUpdates:completion:但删除工作正常,直到添加补充意见。 我可以根据需要提供更多的代码/解释。

如何实现UICollectionView的委托和数据源方法,当它在iOS中的自定义TableViewCell中时,目标C

注意:我不想使用任何第三方库 我有一个自定义table view cell (表视图工作正常)。 现在在table view cell我想实现一个collection view 。 现在我的问题是,我应该在哪里实现集合视图,这是在custom table view cell内的delegate方法和data source方法。 下面是我所尝试过的。 Tabel View Controller实现 – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 5; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { FirstTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tvcell"]; return cell; } 好好工作 现在在这个FirstTableViewCell里面有一个collection view 。 这是我的FirstTableViweCell.h文件 #import […]

UICollectionViewstream布局没有固定的行高

如何修改stream布局,以便在较小和较大的单元格之间具有相同的垂直间距(例如,没有固定的行高度/行高度不固定到最大尺寸)? 我想看这个样子

UICollectionView无法滚动查看整个最后一行

我有一个UICollectionView大小为768×1024,顶部有一个导航栏。 我的自定义UICollectionViewCells大小为200×200 。 问题是,当我不断添加单元格并到达底部行时,我只能看到200×200单元的一部分。 在它反弹之前,它不会让我滚动。 任何想法可能是什么问题? 编辑: 我通过添加单元格: insertItemsAtIndexPaths:

UICollectionViewFlowLayout minimumInteritemSpacing不起作用

我的UICollectionView有两个问题: minimumInteritemSpacing不起作用 它在iOS 6上水平溢出 我设置了这样的布局: UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(70.0f, 70.0f); layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 0.0f; layout.minimumInteritemSpacing = 0.0f; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; // I set the size of _collectionView in layoutSubviews: // _collectionView.frame = self.bounds; _collectionView.contentInset = UIEdgeInsetsMake(8.0f, 8.0f, 8.0f, 8.0f); 该图显示了iOS 6上的结果(在iOS 7上没有溢出,但列之间的间距仍然不为零) 我试过这个解决schemehttps://gist.github.com/OliverLetterer/5583087 ,但它不能解决我的情况。

NSFetchedResultsController更新错误的更新types

请在盲目投票之前查看这些意见。 这不是一个重复的问题。 首先 – 我正在使用MagicalRecord核心数据。 其次 – 我的UICollectionView填充UICollectionView 。 NSPredicate是… NSPredicate *eventPredicate = [NSPredicate predicateWithFormat:@"event = %@", self.event]; NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deleted == NO"]; NSPredicate *compoundPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[eventPredicate, deletedPredicate]]; 当我使用Magical Record的saveWithBlock将新项目添加到CoreData时, collectionView正确更新并将更改animation到视图中。 问题是,当我将更改的值删除到@YES … [MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) { Photo *photo = [[self photoAtIndexPath:[self.collectionView indexPathForCell:cell]] inContext:localContext]; photo.deleted = @YES; }]; 然后NSFetchedResultsController委托方法触发,除非它触发与更改typesNSFetchedResultsChangeUpdate 。 这不是它应该是。 它应该是NSFetchedResultsChangeDelete作为更改已删除的值应从删除请求中删除它。 […]

UICollectionView收到一个索引path不存在的单元格的布局属性

我已经使用UICollection视图来显示网格布局中的项目。 对于数据源,我使用5 * 5维数组。 而且我在numberOfItems中返回5,在numberOfSections中返回5。 然后也是我的应用程序崩溃与以下错误: 'UICollectionView接收到索引path不存在的单元的布局属性:{length = 2,path = 0 – 5}' //////===viewcontroller.m==/////// – (void)viewDidLoad { self.theData = @[@[@"1",@"2",@"3",@"4",@"5"], @[@"6",@"7",@"8",@"9",@"10"],@[@"11",@"12",@"13",@"14",@"15"],@[@"16",@"17",@"18",@"19",@"20"],@[@"21",@"22",@"23",@"24",@"25"]]; MultpleLineLayout *layout = [[MultpleLineLayout alloc] init]; self.collectionView.collectionViewLayout = layout; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.showsVerticalScrollIndicator = NO; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.view.backgroundColor = [UIColor blackColor]; [self.collectionView registerClass:[DataCell class] forCellWithReuseIdentifier:@"DataCell"]; [self.collectionView reloadData]; } – (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section { […]