DCScrollView 1.2.0

DCScrollView 1.2.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年2月

hirohisa维护。



  • Hirohisa Kawasaki

DCScrollView 是 UIScrollView 的扩展,可滚动内容,标题像 Etsy iOS 应用程序一样延迟滚动。

sample

安装

在项目中使用此功能有两种方式

  • DCScrollView/*.{h.m} 复制到您的项目中

  • 使用 CocoaPods 安装并编写 Podfile

platform :ios
pod 'DCScrollView',  '~> 1.1.0'

用法

设置代理和数据源

DCScrollView 使用了一种简单的策略。它定义了一个委托和一个数据源,客户端实现。DCScrollViewDelegate 和 DCScrollViewDataSource 与 UITableViewDelegate 和 UITableViewDataSource 类似。

重新加载

重置单元格并重新显示可见单元格。当前页面在重新加载后保持可见。

- (void)reloadData;

删除缓存

如果 UIViewController 接收到内存警告,则控制 DCScrollView 清除其拥有的内存。

- (void)clearData;

示例

  • 导入 DCScrollView.h
  • 实现 DCScrollViewDataSourceDCScrollViewDelegate 方法

UIViewController

#import "DCScrollView.h"

@interface ExampleViewController ()

<DCScrollViewDataSource, DCScrollViewDelegate>

@end

@implementation ExampleViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    DCScrollView *scrollView = [[DCScrollView alloc]initWithFrame:self.view.bounds];
    scrollView.dataSource = self;
    scrollView.delegate = self;
}

- (NSInteger)numberOfCellsInDCScrollView:(DCScrollView *)scrollView
{
    return 10;
}

- (DCScrollViewCell *)dcscrollView:(DCScrollView *)scrollView cellAtIndex:(NSInteger)index
{
    NSString *identifier = @"Cell";
    DCScrollViewCell *cell = [scrollView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell  = [[DCScrollViewCell alloc] initWithReuseIdentifier:identifier];
    }

    return cell;
}

- (NSString *)titleOfDCScrollViewCellAtIndex:(NSInteger)index
{
    return @"title";
}

将要弃用

- (void)setFont:(UIFont *)font textColor:(UIColor *)textColor highlightedTextColor:(UIColor *)highlightedTextColor

许可证

DCScrollView 可在 MIT 许可证下使用。