2013-04-04 70 views
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); 

我面臨的挑戰是獲得視圖留在細胞。反而會發生什麼,視圖會短暫出現,然後消失。我怎樣才能讓它留下來,一旦發生另一次觸摸事件,我怎麼才能讓它消失?

回答

相關問題