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

标签 ios uitableview uikit

我正在尝试重新创建在许多应用程序中看到的效果,您有一个带有单元格的表格 View ,在单元格上滑动,该 View 将被另一个包含额外按钮的 View 替换。

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

    // 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);

我面临的挑战是让 View 停留在单元格上。取而代之的是 View 短暂出现然后消失。我怎样才能让它停留,然后如何让它在另一个触摸事件发生时消失?

最佳答案

关于ios - 在 UITableViewCell 子类中实现自定义滑动功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15800842/

相关文章:

ios - 崩溃 UIScrollView EXC_BAD_ACCESS

ios - IOS 7和多任务处理上的终止的应用程序

iOS7 后台同步(使用 NSURLSessionDataTask?)

ios - UITabBarController 内的 UITableView 不工作

iphone - 在 viewWillDisappear 期间隐藏 UINavigationController 的 UIToolbar :

ios - 使用 UIDynamics 重力为 CGRects 设置动画

ios - 适用于iOS应用开发和生产的Fabric

ios - 在 Button Swift 中通过标签发送行和部分

ios - 调整 UITableView 到 iPhone 5/5s

ios - Facebook 登录完成后的 UITableView reloadData()