我正在做一个项目,它有许多图像显示在网络数据的 Collection View 中。
我已经实现了 WaterFlowLayout Collection View 开源 Github 项目 https://github.com/aceisScope/WaterflowView
图像动态分配给 Collection View 图像数组..
如果 Collection View 源中的图像数量为 3 个或更多,则工作正常..
但是如果要显示的图像数量少于 3,则它不会显示在收藏 View 中。 在演示项目中也发生了同样的事情..
还有一件事我也实现了拉动刷新,但是在单页中可以显示近 12 张图像,如果图像数量超过 13 个,默认滚动工作正常,我可以拉动刷新,但如果图像计数小于 12,我无法访问刷新 Collection View 。
如果 numberOfItemsInSection 是 3 并且 numberOfColumnsInFlowLayout 也是 3 意味着它完成 一整行比代码可以正常工作。
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 3;
}
#pragma mark- UICollectionViewDatasourceFlowLayout
- (NSInteger)numberOfColumnsInFlowLayout:(WaterFlowLayout*)flowlayout
{
return 3;
}
但是如果 numberOfItemsInSection 是 2 并且 numberOfColumnsInFlowLayout 也是 3 意味着它没有完成一整行我无法显示图像。
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 2;
}
#pragma mark- UICollectionViewDatasourceFlowLayout
- (NSInteger)numberOfColumnsInFlowLayout:(WaterFlowLayout*)flowlayout
{
return 3;
}
即使排序规则 View 默认滚动未激活,任何人都可以建议一些技巧来启用拉动刷新..
提前致谢...
最佳答案
您可以考虑跳过 WaterFlowLayout 存储库,而只使用 UICollectionView:
要开始使用 UICollectionView,请查看 this excellent tutorial布莱恩·汉森 (Bryan Hansen) 着。它会让您熟悉 UICollectionView。
如果您使用的是 UICollectionView,则只需在
UICollectionViewController
的viewDidLoad
中添加几行代码即可添加下拉刷新控件方法:UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(startRefresh:) forControlEvents:UIControlEventValueChanged]; [self.collectionView addSubview:refreshControl];
要实现 Pinterest 风格的瀑布布局,您可以使用此 UICollectionViewLayout github 存储库,或任何数量的其他存储库:https://github.com/jayslu/JSPintDemo
关于iphone - CollectionView Ios 6 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13965529/