在UITableViewCell子类中实现自定义滑动功能

时间:2013-04-04 00:59:41

标签: ios uitableview uikit

我正在尝试重新创建在许多应用中看到的效果,您有一个带有单元格的表视图,在单元格上滑动,视图被另一个包含其他按钮的视图替换。

我尝试按以下方式执行此操作:

    // Hacky hacky
    RCTReceiptCell *selectedCell = (RCTReceiptCell *)[sender view];

    RCTReceiptOptionsCell *optionsCell = [[RCTReceiptOptionsCell alloc] init];

    if (optionsCell) {
        NSBundle *mainBundle = [NSBundle mainBundle];
        NSString *class = NSStringFromClass([RCTReceiptOptionsCell class]);
        NSArray *cellComponents = [mainBundle loadNibNamed:class
                                                     owner:self
                                                   options:nil];
        optionsCell = [cellComponents objectAtIndex:0];
    }

    // Make sure subview gets inserted on top.
    NSArray *subviews = [[selectedCell contentView] subviews];
//  NSUInteger index = [subviews indexOfObject:[subviews lastObject]];
    UIView *selectedCellContentView = selectedCell.contentView;
    [selectedCell insertSubview:optionsCell aboveSubview:selectedCell.contentView];
    NSLog(@"subviews: %@",selectedCellContentView.subviews);

我面临的挑战是让观点留在牢房里。相反的是,视图会短暂出现然后消失。我怎样才能让它留下来,然后一旦发生另一次触摸事件,我怎么能让它消失?

1 个答案:

答案 0 :(得分:2)

相关问题