Tag: uicollectionview

layoutAttributesForSupplementaryViewOfKind:atIndexPath:传入不正确的indexPath

我有一个自定义的UICollectionViewLayout ,它使用补充视图在每个页面的底部放置一个页脚。 这似乎一直工作,直到我开始在页面的底部插入单元格。 由于补充视图必须链接到UICollectionView中的NSIndexPath,因此在准备布局方法中,我检测页面上的最后一个单元格,然后将补充视图的layoutAttributes存储到页面上的最后一个indexPath。 这是插入新单元格之前的集合视图布局: |- Page 1 |– [0, 0] |– [0, 1] |– [0, 2] |- Footer (indexPath [0, 2]) |- Page 2 |– [1, 0] |– [1, 1] |- Footer (indexPath [1, 1]) 正如所料,我的prepareLayout方法创build和存储UICollectionViewLayoutAttributespath[0, 2]和[1, 1] [0, 2] UICollectionViewLayoutAttributes。 layoutAttributesForSupplementaryViewOfKind:atIndexPath:方法也被调用两次,返回indexPaths( [0, 2]和[1, 1] )的正确属性 现在的问题是,当我在索引[1, 2]处插入新的单元格时[1, 2] prepareLayout方法正确地重新计算布局,并像预期的那样将第二个页脚的indexPath更改为[1, 2] 。 但是,当再次调用layoutAttributesForSupplementaryViewOfKind:atIndexPath:来更新接口时,其indexPath属性仍然返回[1, 1] […]

PAC提取失败,错误

我在日志中看到这个错误,我不知道这是什么意思: PAC Fetch failed with error [NSURLErrorDomain:-1003] 2017-06-08 17:07:56.157874+0200 xxxxxx[27059:7093559] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1003 同时,我的应用程序中有一个collectionView的问题。 不知道是否与错误有关: 有时,只有当我们公司的一个远程办公室使用这个应用程序时,无论是模拟器还是一个真实的设备,一个仅仅接收图像数组并显示在屏幕上的collectionView就停止工作。 这不像它不只是加载图像,它似乎像整个collectionView不显示。 我正在testing与另一个办公室(另一个城市)的模拟器和设备相同的应用程序,它从来没有发生过我。 除此之外,“PAC”错误,我只看到一些自动布局约束的问题,但我看到在我的日志相同的错误,它仍然是完美的。 在远程位置testing应用程序的人说,他们必须删除并重新安装应用程序,使其再次工作。 任何线索?

UICollectionView单元布局超出了集合视图的范围

我有一个UICollectionView,它使用stream布局来放置它的单元格。 它是垂直滚动。 它填充320×480的屏幕,并显示一个总是96 * 96的自定义UICollectionViewCell – 大小是在Interface Builder中设置的,委托没有实现方法来设置每个项目的项目大小。 左右各有10个插图,最小间距设置为6px。 因此会发生什么是每个水平线3个单元格。 <-10 – > <—- —- 96> < – 6 – > <—- —- 96> < – 6 – > <—- —- 96> < – 10-> = 320。 我遇到的问题是偶尔会在一行上放置4个单元格! 第四个单元大部分在屏幕之外。 然后在下面一行放置2个单元来补偿。 整个stream程布局的关键在于它是一个破线的布局,不应该把任何东西放在屏幕外! 我附上了一张照片: 请注意,在第二行中,大部分屏幕上还有第四项。 我真的不知道是什么原因造成的。 单元格dynamic填充数据,但大小不变。 所有其他行上的单元格都很合适,所以没有理由在某些行上这会发生。 每次收集视图更新时,此错误都会发生在不同的位置。 即。 它可能发生在第2行,那么一旦更新发生,它可能发生在第10行,依此类推。 收集视图正在由定时器更新。 定时器本质上是调用处理某些数据的函数,然后使用dispatch_async(在主队列上)更新包含后备数据的数组,并调用[collectionView reloadData]。 所以我没有更新从主线程以外的任何线程的集合视图。 后备数组只在主队列和该函数中更新; 不从其他地方。 […]

layoutAttributesForSupplementaryViewOfKind没有被调用

我正在为UICollectionView编写自定义stream布局。 我可以看到并滚动单元格。 问题是我不能使节标题的补充视图出现。 所以, – (UICollectionViewLayoutAttributes *) layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath 永远不会被调用。 在数据源中这个方法: – (UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath 也永远不会被调用 。 我怎样才能使这些方法被称为? 编辑:这是layoutAttributesForElementsInRect: – (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSMutableArray * attributes = [NSMutableArray arrayWithCapacity:[[self.layoutInfo allKeys] count]]; for(NSIndexPath * indexPath in self.layoutInfo) { UICollectionViewLayoutAttributes *itemAttributes = [self.layoutInfo objectForKey:indexPath]; if(CGRectIntersectsRect(rect, itemAttributes.frame)) { [attributes addObject:itemAttributes]; } […]

预先填充UICollectionView单元重用队列

问题 我有一个应用程序与一个单一的UICollectionView ,这是第一次口吃,我滚动它。 我已经把源代码缩小到新的单元格(2)正在被创build的事实(使用initWithFrame:因为没有单元格躺在被重用。 在第一次滚动之后,重用队列不是空的,单元格可以重复使用,不会出现口吃。 黑客 所以我已经能够在iOS运行时头文件中的私有方法的帮助下解决这个问题: – (void)_reuseCell:(id)arg1; 我的假设是,这是细胞被添加到重用队列中的地方。 使用这个未logging的方法的黑客看起来像这样: int prefillCellCount = 10; NSMutableArray *cells = [[NSMutableArray alloc] initWithCapacity:prefillCellCount]; for (int i=0; i<10prefillCellCount i++) { UICollectionViewCell *cell = [self.gridView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; [cells addObject:cell]; } for (UICollectionViewCell *cell in cells) { [self.gridView _reuseCell:cell]; } 黑客的作品! 滚动时没有口吃。 问题 我不认为我能通过这个黑客过去的App Store审查。 有没有办法做到这一点,而不使用无证方法? 如果没有,是我唯一的手段只是混淆黑客?

如何在所有单元格周围的空白区域接收UICollectionView的触摸

我有一个UICollectionView有不同的项目。 当我点击一个项目,我使用: -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 找出什么被触动,然后基本上设置该视图的α为0来隐藏它。 这一切工作正常。 现在我想要做的是当你点击围绕所有UICollectionViewCell所有的视图再次出现。 我很难find一种方法,可以让我知道单元格周围的空白区域何时被触摸。 有没有一个很好的方法来做到这一点? 我曾尝试设置一个手势识别器,但是当我这样做,我的方法 -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 不叫。 是否有一些方法来实现手势识别器,并从那里确定是否点击一个单元格,如果隐藏该单元格,否则显示所有隐藏的单元格? 谢谢。

UITableView“beginUpdates”和UICollectionView“performBatchUpdates”是否有相同的行为?

当我开始想知道UITableView中的“beginUpdates”和UICollectionView中的“performBatchUpdates”是否具有相同的行为时,我正在浏览文档。 如果是这样,是否有一个原因,他们叫不同,即使他们几乎是一样的东西? 谢谢!

显示黑屏而不是UICollectionView

我试图重新实现在这里看到的不定式滚动UICollectionView 。 对我而言缺less的东西: ViewController.h : @interface ViewController : UIViewController<UICollectionViewDataSource, UICollectionViewDelegate> @end DataCell.h : @interface DataCell : UICollectionViewCell @property (nonatomic, strong) UILabel *label; @end DataCell.m : #import "DataCell.h" @implementation DataCell -(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if(self){ self.label = [[UILabel alloc] initWithFrame:self.bounds]; self.autoresizesSubviews = YES; self.label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); self.label.textAlignment = NSTextAlignmentCenter; self.label.adjustsFontSizeToFitWidth = YES; […]

将CollectionViewView照片传递给电子邮件附件iOS swift

我从照片库中select了一些照片,并填充到collectionView中。 那么我的collections视图里面会有一些照片。 这里是我的代码获取照片到collections视图。 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell: PhotoCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("PhotoCell", forIndexPath: indexPath) as! PhotoCollectionViewCell let asset : PHAsset = self.photoAsset[indexPath.item] as! PHAsset PHImageManager.defaultManager().requestImageForAsset(asset, targetSize: PHImageManagerMaximumSize, contentMode: .AspectFill, options: nil, resultHandler: {(result, info)in if let image = result { cell.setThumbnailImage(image) } }) return cell } 但是,如何将位于集合视图中的所有这些照片传递给电子邮件附件? 下面的代码是电子邮件附件,我如何将所有的照片传递给这个附件? let emailTitle […]

来自xib文件的UICollectionViewCell不会在UICollectionView中显示

我有一个定制的xib文件,其中包含一个标签和一个UICollectionView 。 我有一个集合视图的单元格与UICollectionViewCell的自定义子类的第二个xib文件。 父xib文件的所有者如下所示 – import UIKit class PackageSizePickerVC: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { @IBOutlet weak var collection: UICollectionView! let sizes: [PackageSize] = { let small = PackageSize(title: "Small", imageName: "S") let medium = PackageSize(title: "Medium", imageName: "M") let large = PackageSize(title: "Large", imageName: "L") let extralarge = PackageSize(title: "Extra Large", imageName: "XL") return [small, […]