SWRevealTableViewCell 0.3.5

SWRevealTableViewCell 0.3.5

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

John-Lluch维护。



  • John Lluch Zorrilla

SWRevealTableViewCell 是 UITableViewCell 的子类,可以轻松显示基于用户滑动手势或开发者程序化操作的左右按钮。与 iOS8 邮件应用类似,但增加了更多功能。

特性

  • 支持任何组合的左右功能按钮。
  • 在 iOS7 和 iOS8 上都能正常工作,没有问题
  • 功能按钮的完整进入和退出动画,带有阻尼效果。
  • 通过提供 SWCellButtonItems 数组来指定按钮,类似于 UIToolBarItems。
  • 项目可以包含文本、图像或两者都包含。
  • 可以单独配置项目大小。
  • 通过调用处理程序块来提供项目操作。
  • 提供方便的 UIActionSheet 类别方法 'showFromCellButtonItem:animated:' 来显示菜单项
  • 正确处理旋转和单元格/表格大小调整。
  • 单元格或表格视图上的透明度、背景颜色或图像没有问题。
  • 单元格上的附加视图没有问题。
  • API 比 UIToolbar 更简单。
  • 滑动手势识别器的无缝集成,表现如丝般顺滑。
  • 提供全面的委托方法,以获取控制器的完整状态,并实现您自己的代码挂钩,以自定义行为。
  • 轻量级、简洁、易于阅读、自文档化代码,您将在项目中喜欢使用它。

YouTube 视频教程

http://youtu.be/jlaWQsWinoU (新)

http://youtu.be/v6GAGdf_Kkg

示例

仓库包含以下示例项目,可用于模板或测试目的

  • RevealTableViewCellExample.xcodeproj

Image      Image      Image      Image

需求

  • iOS 7.0 或更高版本。
  • Objective-C, ARC。

使用方法

SWRevealTableViewCell 仓库尝试提供一个更新的 cocoaPods 文件和一致的标签版本号,但在 cocoapods-specs 仓库中没有活跃更新。

安装它的最简单方法是将其复制到您的项目中

  • SWRevealTableViewCell.h
  • SWRevealTableViewCell.m

在您的项目上

  • 在 cellForRowAtIndexPath 中初始化 SWRevealTableViewCell 实例,或将其注册为与您 table view 一起使用
  • 在 cellForRowAtIndexPath 中为 SWRevealTableViewCell 实例设置 dataSource 和可选的 delegate。
  • 实现以下两个 dataSource 方法以返回 SWCellButtonItems 的数组
    • (NSArray*)leftButtonItemsInRevealTableViewCell:(SWRevealTableViewCell *)revealTableViewCell
    • (NSArray*)rightButtonItemsInRevealTableViewCell:(SWRevealTableViewCell *)revealTableViewCell

基本 API 说明

为您的 tableView 注册 SWRevealTableViewCell

[tableView registerClass:[SWRevealTableViewCell class] forCellReuseIdentifier:RevealCellReuseIdentifier];

创建单元格实例

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SWRevealTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RevealCellReuseIdentifier forIndexPath:indexPath];

    cell.dataSource = self;
    .
    .
}

提供按钮项

- (NSArray*)rightButtonItemsInRevealTableViewCell:(SWRevealTableViewCell *)revealTableViewCell
{
    SWCellButtonItem *item1 = [SWCellButtonItem itemWithTitle:@"Delete" handler:^(SWCellButtonItem *item, SWRevealTableViewCell *cell)
    {
        NSLog( @"Delete");
    }];

    item1.backgroundColor = [UIColor redColor];
    item1.tintColor = [UIColor whiteColor];
    item1.width = 75;

    return @[item1];
}

左/右项的程序动画。位置可以是: SWCellRevealPositionLeftSWCellRevealPositionCenterSWCellRevealPositionRight

- (void)setRevealPosition:(SWCellRevealPosition)revealPosition animated:(BOOL)animated;

其他方法在 SWRevealTableViewCell.h 声明文件中有文档说明。

发布说明

发布说明更新在类的主体头文件中。请参阅 SWRevealTableViewCell.h

许可协议

版权(c)2013 Joan Lluch [email protected]

兹特此授权,任何人获得此软件及其相关文档(“软件”)的副本,可以不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供者提供软件的人这样做,前提是以下条件

上述版权声明和本授权声明应包含在软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何形式的保证,包括但不仅限于对适销性、特定用途适用性和非侵权性的保证。在任何情况下,作者或版权持有人不对任何索赔、损害或其他责任承担任何责任,无论这些责任源于合同、侵权或其他,无论是否与软件、软件的使用或其他方式有关。