MKSlidingTableViewCell 0.8

MKSlidingTableViewCell 0.8

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布Dec 2014

Michael Kirk 维护。



  • Michael Kirk 和 Sam Corder

一款 iOS 7 风格的滑动表格单元格。在您的表格视图中使用 MKSlidingTableViewCell,您可以将任何视图设置为“抽屉视图”,然后设置揭示量来指定在拖拽时滚动视图将停留在何处。由于 MKSlidingTableViewCell 使用滚动视图作为单元格内容的容器,因此在滑动单元格时,它将像预期的那样跟踪和弹跳。如下面的截图所示,您可以模仿 iOS 7,也可以自定义您想要的任何方式!

iOS 7 Mail Style Screenshot Custom Style Screenshot

使用方法

设置

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MKSlidingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"container"];
    UITableViewCell *foregroundCell = [tableView dequeueReusableCellWithIdentifier:@"foreground"];
    UITableViewCell *backgroundCell = [tableView dequeueReusableCellWithIdentifier:@"background"];

    cell.foregroundView = foregroundCell;
    cell.drawerView = backgroundCell;
    cell.drawerRevealAmount = 146;
    cell.delegate = self;

    //configure cells

    return cell;
}

处理单元格上的点击

- (void)didSelectSlidingTableViewCell:(MKSlidingTableViewCell *)cell
{
    //cell tapped!
}

通知

//Add observers
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRevealDrawerViewForCell:) name:MKDrawerDidOpenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didHideDrawerViewForCell:) name:MKDrawerDidCloseNotification object:nil];

- (void)didRevealDrawerViewForCell:(NSNotification *)notification
{
    MKSlidingTableViewCell *cell = notification.object;

    //additional code
}

- (void)didHideDrawerViewForCell:(NSNotification *)notification
{
    MKSlidingTableViewCell *cell = notification.object;

    //additional code
}

致谢

MKSlidingTableViewCell 是由 Michael Kirk 创建的,并有 Sam Corder 的贡献。

许可证

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