简体   繁体   中英

How to add panMovement to UITableView Cell

I have a table and custom cell from NIB. Basically what I need is to slide the custom cell from the table to the right side. It has to be smooth, and the table itself should not collapse. (The cell will get back after the action is done). I have some number of sections, and 1 row/section, so basically I need to move with the section. Thanks a lot for the answer!

My cell.m file looks like this:

#import "MIKETableViewCell.h"

static NSString *CellTableIdentifier = @"MIKETableViewCell";

@implementation MIKETableViewCell

@synthesize timeLabel = _timeLabel;
@synthesize priceLabel = _priceLabel;
@synthesize infoLabel = _infoLabel;


- (void)awakeFromNib
{
    // Initialization code
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:CellTableIdentifier];

return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

// Configure the view for the selected state
}


@end

add this:

 -(void)layoutSubviews
 {
     UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tableCellClicked)];
    tapGesture.numberOfTapsRequired = 1;
    [self addGestureRecognizer:tapGesture];
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM