Skip to content

Commit

Permalink
Fix issue MortimerGoro#190
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Apr 2, 2016
1 parent 7b86ec9 commit 3bf460c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,8 @@ -(instancetype) initWithButtons:(NSArray*) buttonsArray direction:(MGSwipeDirect
for (UIView * button in _buttons) {
if ([button isKindOfClass:[UIButton class]]) {
UIButton * btn = (UIButton*)button;

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];
[btn removeTarget:nil action:@selector(mgButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; //Remove all targets to avoid problems with reused buttons among many cells
[btn addTarget:self action:@selector(mgButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
if (!differentWidth) {
button.frame = CGRectMake(0, 0, maxSize.width, maxSize.height);
Expand All @@ -116,7 +110,7 @@ -(void) dealloc
{
for (UIView * button in _buttons) {
if ([button isKindOfClass:[UIButton class]]) {
[(UIButton *)button removeTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[(UIButton *)button removeTarget:self action:@selector(mgButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
}
}
Expand Down Expand Up @@ -296,7 +290,7 @@ -(BOOL) handleClick: (id) sender fromExpansion:(BOOL) fromExpansion

}
//button listener
-(void) buttonClicked: (id) sender
-(void) mgButtonClicked: (id) sender
{
[self handleClick:sender fromExpansion:NO];
}
Expand Down

0 comments on commit 3bf460c

Please sign in to comment.