IAInfiniteGridView 0.1.4

IAInfiniteGridView 0.1.4

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2014年12月

Ikhsan Assaat 维护。




  • Ikhsan Assaat

image image

具有 UITableView 样数据源方法的无尽网格视图

如果您想要具有我们自己的网格的无尽滚动视图,只需将 IAInfiniteGridView 拖放到项目中,设置并实现其数据源即可!

功能

  • 循环模式
  • 自定义分页启用
  • 易于实现的数据源方法
  • 使用重用队列以实现更好的性能
  • 此外,还可以委托方法来接受选择的网格

如何使用

  • IAInfiniteGridView 拖放到您的项目中
  • 通过代码或 Interface Builder 添加类
  • 设置您的视图控制器以遵守 IAInfiniteGridDataSource
  • 通过代码设置其数据源:``` infiniteGridView.dataSource = self
or via IB by ctrl+drag it to your view controller and add as its `dataSource`

* Implement the required data source methods

``` objective-c
- (UIView *)infiniteGridView:(IAInfiniteGridView *)gridView forIndex:(NSInteger)gridIndex {
    UIView *grid = [self.gridView dequeueReusableGrid];

    CGFloat gridWidth = [self infiniteGridView:gridView widthForIndex:gridIndex];
    CGRect frame = CGRectMake(0.0, 0.0, gridWidth, gridView.bounds.size.height);

    UILabel *numberLabel;
    if (grid == nil) {
        grid = [[UIView alloc] initWithFrame:frame];

        numberLabel = [[UILabel alloc] initWithFrame:frame];
        [numberLabel setBackgroundColor:[UIColor clearColor]];
        [numberLabel setTextColor:[UIColor whiteColor]];
        [numberLabel setFont:[UIFont boldSystemFontOfSize:(gridView.bounds.size.height * .4)]];
        [numberLabel setTextAlignment:NSTextAlignmentCenter];
        [numberLabel setTag:kNumberLabelTag];
        [grid addSubview:numberLabel];
    } else {
        grid.frame = frame;
        numberLabel = (UILabel *)[grid viewWithTag:kNumberLabelTag];
        numberLabel.frame = frame;
    }

    // set properties    
    NSInteger mods = gridIndex % [self numberOfGridsInInfiniteGridView:gridView];
    if (mods < 0) mods += [self numberOfGridsInInfiniteGridView:gridView];
    CGFloat red = mods * (1 / (CGFloat)[self numberOfGridsInInfiniteGridView:gridView]);
    grid.backgroundColor = [UIColor colorWithRed:red green:0.0 blue:0.0 alpha:1.0];

    // set text
    [numberLabel setText:[NSString stringWithFormat:@"[%d]", gridIndex]];

    return grid;
}

// this method is used for circular mode, not very useful for infinite mode
- (NSUInteger)numberOfInfiniteGrids {
    return 10;
}

- (CGSize)infiniteGridSize {    
    return CGSizeMake(150.0, 150.0);
}
  • 尽情地滚动吧!

为了更加清晰,请参阅示例项目中 Infinite 的代码。

待办事项

  • 水平滚动
  • 自定义分页改进
  • 自定义标识符

依赖关系

[iOS 5.0+] - 使用禁用 ARC 的 iOS 5 构建

许可协议

IAInfiniteGridView 可在 MIT 许可协议下使用。

版权所有 (c) 2013 Ikhsan Assaat

兹特此授予任何人免费获取本软件及其相关文档文件(以下简称“软件”)的副本的权利,包括但不仅限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许接收软件的人进行此类操作,但前提是

上述版权声明和本许可声明应包含在所有副本或软件的实质性部分中。

软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于对适销性、适用于特定目的和不受侵权的保证。在任何情况下,作者或版权所有者均不应对任何索赔、损害或其他责任承担任何责任,无论该索赔、损害或其他责任是基于合同、侵权或其他方式,源于、因或与软件的使用或任何其他方式使用有关。

致谢

IAInfiniteGridView 由 Ikhsan Assaat 创建。

请随时联系我: