多くのアプリで見られる効果を再現しようとしています。セルを含むテーブル ビューがあり、セルをスワイプすると、ビューが追加のボタンを含む別のビューに置き換えられます。
私は次のようにこれをやろうとしました:
// 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);
私が直面した課題は、セルにとどまるように見えるようにすることでした。代わりに、ビューが一時的に表示されてから消えます。どうすればそれをそのままにして、別のタッチイベントが発生したらどうすれば消えますか?