PMBrowsingCollectionView 0.9.1

PMBrowsingCollectionView 0.9.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2014年12月

Peter Meyers 维护。



 
依赖
PMUtils>= 0
PMCircularCollectionView>= 0
 

  • Peter Meyers

PMBrowsingCollectionView 是 UICollectionView 的子类,通过引入展开和折叠段的概念,实现了一种新的交互,便于浏览一系列单元格。

Demo

需求 & 备注

  • PMBrowsingCollectionView 专为 iOS 构建,并需要 iOS 7 或更高版本。
  • 正在编写头文件的详细注释。(2014年6月12日)。
  • PMBrowsingCollectionView 不会支持调整大小,直到 iOS8 中添加动态单元格调整大小。

如何开始

  • 查看文档(即将推出)。

Podfile

为了安装,只需将以下行添加到您的 Podfile 中。

platform :ios, '7.0'
pod "PMBrowsingCollectionView"

用法

要查看 PMBrowsingCollectionView 的实际应用,请运行位于 /Example/PMBrowsingCollectionView-iOSExample.xcworkspace 的示例项目。在安装 PMBrowsingCollectionView pod 后,将其整合到项目中的方式与创建典型的 UICollectionView 相似。

UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
layout.minimumInteritemSpacing = 2.0f;
layout.minimumLineSpacing = 2.0f;

PMBrowsingCollectionView *collectionView = [PMBrowsingCollectionView collectionViewWithFrame:self.view.bounds
                                                                            collectionViewLayout:layout];
collectionView.delegate = self;
collectionView.dataSource = self;
[collectionView registerClass:[UICollectionViewCell class]
            forCellWithReuseIdentifier:@"cellReuseIdentifier"];
[collectionView registerClass:[UICollectionReusableView class]
            forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                   withReuseIdentifier:@"headerReuseIdentifier"];
[self.view addSubview:collectionView];
- (UICollectionViewCell *)collectionView:(PMBrowsingCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellReuseIdentifier" forIndexPath:indexPath];
    NSUInteger normalizedIndex = [collectionView normalizeItemIndex:indexPath.item forSection:indexPath.section];
    /*
    * Configure cell based on indexPath.section and normalizedIndex
    */
    return cell;
}

PMBrowsingCollectionViewDelegate 为 UICollectionViewDelegateFlowLayout 添加了三个可选方法

- (CGFloat) collectionView:(PMBrowsingCollectionView *)collectionView shadowRadiusForSection:(NSInteger)section
{
    return 20.0f;
}

- (UIColor *) collectionView:(PMBrowsingCollectionView *)collectionView shadowColorForSection:(NSInteger)section
{
    return [UIColor blackColor];
}

// Only called when section is in a collapsed state.
- (void) collectionView:(PMBrowsingCollectionView *)collectionView willCenterItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger normalizedIndex = [collectionView normalizeIndex:indexPath.item];
    DLog(@"Will center cell at section index %d, item index %d", indexPath.section, normalizedIndex);
}

讨论

  • 为了实现无限滚动,PMBircularCollectionView 使用在这篇博客文章中描述的技术,它将内容大小和索引路径的数量相乘。因此,当在-collectionView:numberOfItemsInSection:代理方法中返回少于 16 个项目时,dataSource 和 delegate 方法可能传递一个带有 item == 15 的索引路径。如上例所示,调用 -normalizeItemIndex:forSection 来更改项目索引到正确的值。

通讯

  • 如果您需要帮助,请使用 Stack Overflow.(标签 'PMTabBarController')
  • 如果您想询问一个一般问题,请使用 Stack Overflow.
  • 如果您发现了一个错误,请打开一个问题。
  • 如果您有功能请求,请打开一个问题。
  • 如果您想做出贡献,请提交一个 pull request。

作者

许可证

PMBrowsingCollectionView 可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。