Skip to content

Commit

Permalink
Merge pull request MortimerGoro#181 from longlongjump/master
Browse files Browse the repository at this point in the history
Fix button target removing
  • Loading branch information
MortimerGoro committed Mar 20, 2016
2 parents 303f446 + 0576a07 commit bb55e6a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ -(instancetype) initWithButtons:(NSArray*) buttonsArray direction:(MGSwipeDirect
for (UIView * button in _buttons) {
if ([button isKindOfClass:[UIButton class]]) {
UIButton * btn = (UIButton*)button;
[btn removeTarget:nil action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; //Remove all targets to avoid problems with reused buttons among many cells

for (id target in btn.allTargets) {
if ([target isKindOfClass:self.class]) {
[btn removeTarget:target action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; //Remove all targets to avoid problems with reused buttons among many cells
}
}

[btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
if (!differentWidth) {
Expand Down

0 comments on commit bb55e6a

Please sign in to comment.