SAScrollTableViewCell 0.3.0

SAScrollTableViewCell 0.3.0

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

Shams Ahmed 维护。




  • 作者:
  • shams ahmed

目的

这是一个易于使用的 UITableViewCell 子类,实现了一个带有媒体内容的滚动效果单元格,如图像、视频、声音等...

让我们看看示例

Screenshot:

用法

要运行示例项目;请克隆仓库,然后首先从项目目录运行 pod install。

如何使用

导入类 #import "SAScrollTableViewCell.h" 并添加其代理 SAScrollTableViewCellDelegate

在 init 或 viewDidLoad 方法中注册类 [self.tableView registerClass:[SAScrollTableViewCell class] forCellReuseIdentifier:@"Cell"];。在 heightForRowAtIndexPath 中设置单元格的高度为 140。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *const cellIdentifier = @"Cell";
    SAScrollTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (!cell) {
        cell = [[SAScrollTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

    }

    cell.delegate = self;

    [cell setMedia:@[
                     [SAScrollMedia mediaWithType:SAMediaTypeVideoAsset
                                            title:@"title"
                                           object:[[NSBundle mainBundle] URLForResource:@"sample1" withExtension:@"mov"]],
                     [SAScrollMedia mediaWithType:SAScrollMediaTypeImageName title:@"title" object:@"sample1.jpg"],
                     [SAScrollMedia mediaWithType:SAScrollMediaTypeImageName title:@"title" object:@"sample2.jpg"],
                     [SAScrollMedia mediaWithType:SAScrollMediaTypeImageName title:@"title" object:@"sample3.jpg"]
                     ]];

    return cell;
}

添加媒体内容

SAScrollTableViewCell 预期使用 SAScrollMedia,它包含每个媒体内容,如图像、视频和声音。使用工厂方法创建对象 mediaWithType:(SAScrollMediaType)type title:(NSString *)title object:(id)object;。目前只支持四种媒体类型,使用以下键:

typedef NS_ENUM(NSUInteger, SAScrollMediaType) {
    /**
     *  UIImage object
     */
    SAScrollMediaTypeImageObject,
    /**
     *  name of a file within main bundle i.e sample1.png
     */
    SAScrollMediaTypeImageName,
    /**
     *  NSData of a image
     */
    SAScrollMediaTypeRawImage,
    /**
     *  NSURL of a link to a video file supported by iOS
     */
    SAScrollMediaTypeVideoAsset,
    /**
     *  NSURL link of image on the web i.e http://lorempixel.com/250/250/
     */
    SAScrollMediaTypeImageURL
    /**
     *  for subclassing
     */
    SAScrollMediaTypeOther
};

需求

iOS 7,仅支持横屏

安装

作者

shams ahmed,[email protected]

许可证

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