Skip to content

Commit

Permalink
Fixed issue MortimerGoro#31: Swipe doesn't work for cached cells afte…
Browse files Browse the repository at this point in the history
…r data reload
  • Loading branch information
MortimerGoro committed Nov 10, 2014
1 parent b1c1178 commit 430fbe9
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -368,23 +368,23 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self initViews];
[self initViews:YES];
}
return self;
}

- (id)initWithCoder:(NSCoder*)aDecoder
{
if(self = [super initWithCoder:aDecoder]) {
[self initViews];
[self initViews:YES];
}
return self;
}

-(void) awakeFromNib
{
if (!_panRecognizer) {
[self initViews];
[self initViews:YES];
}
}

Expand All @@ -393,14 +393,16 @@ -(void) dealloc
[self hideSwipeOverlayIfNeeded];
}

-(void) initViews
-(void) initViews: (BOOL) cleanButtons
{
_leftButtons = [NSArray array];
_rightButtons = [NSArray array];
_leftSwipeSettings = [[MGSwipeSettings alloc] init];
_rightSwipeSettings = [[MGSwipeSettings alloc] init];
_leftExpansion = [[MGSwipeExpansionSettings alloc] init];
_rightExpansion = [[MGSwipeExpansionSettings alloc] init];
if (cleanButtons) {
_leftButtons = [NSArray array];
_rightButtons = [NSArray array];
_leftSwipeSettings = [[MGSwipeSettings alloc] init];
_rightSwipeSettings = [[MGSwipeSettings alloc] init];
_leftExpansion = [[MGSwipeExpansionSettings alloc] init];
_rightExpansion = [[MGSwipeExpansionSettings alloc] init];
}
_panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panHandler:)];
[self addGestureRecognizer:_panRecognizer];
_panRecognizer.delegate = self;
Expand Down Expand Up @@ -592,7 +594,8 @@ -(void) prepareForReuse
{
[super prepareForReuse];
[self cleanViews];
[self initViews];
BOOL cleanButtons = _delegate && [_delegate respondsToSelector:@selector(swipeTableCell:swipeButtonsForDirection:swipeSettings:expansionSettings:)];
[self initViews:cleanButtons];
}

-(void) setEditing:(BOOL)editing animated:(BOOL)animated
Expand Down

0 comments on commit 430fbe9

Please sign in to comment.