1
我试图重新创建在许多应用程序中看到的效果,您有一个单元格的表格视图,在单元格上滑动并且视图被另一个包含其他按钮的视图替换。在UITableViewCell子类中实现自定义滑动功能
我试图做到这一点,如下所示:
// 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);
我面临的挑战是获得视图留在细胞。反而会发生什么,视图会短暂出现,然后消失。我怎样才能让它留下来,一旦发生另一次触摸事件,我怎么才能让它消失?