uicollectionview加载的很好
我使用flowlayout as创build了一个带有自定义集合cell.set的集合视图
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; [flowLayout setItemSize:CGSizeMake(250, 480)]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; [self.templateCollectionView setCollectionViewLayout:flowLayout];
我把它设置成水平的,但是仍然有一个单元格错位,请看att mmp
错误的位置,如果我们滚动并重新加载它,它将返回到正确的位置。 任何人都可以提出这是什么错?
有一个解决这个问题的方法适用于我。 下面是我用于水平滚动编辑的修复。 基本上只是过滤掉下面提供坏帧的属性项目。
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSArray *attributes = [super layoutAttributesForElementsInRect:rect]; NSMutableArray *newAttributes = [NSMutableArray arrayWithCapacity:attributes.count]; for (UICollectionViewLayoutAttributes *attribute in attributes) { if (attribute.frame.origin.y + attribute.frame.size.height <= self.collectionViewContentSize.height) { [newAttributes addObject:attribute]; } } return newAttributes; }
这通常发生在我们没有给出适当的细胞间隔时。 确保在填充uicollectionview的单元格时,应该给出单元格间距。 也通过UICollectionView flowLayout不正确地包装单元格(iOS)可能会帮助你。
- 如何在Swift中用string初始化NSTextStorage
- NSDictionary使用SwiftyJSON将jsonstring转换为json对象
- Swift计算UITextFields的值并返回值
- 如何使CAShapeLayer中的dynamicstrokeColor? 在Swift中
- 呈现视图控制器而不更改状态栏颜色,如UIAlertController
- NSJSONSerialization不工作,NSUTF8StringEncoding正在工作
- iOS应用程序中Tesseract集成中的错误
- (IOS)cordova相机插件参考删除的图像
- networking连接丢失NSURLConnection