Skip to content

Commit

Permalink
Replace duplicated init code with a common init method
Browse files Browse the repository at this point in the history
  • Loading branch information
rhult committed Sep 30, 2012
1 parent 3adb728 commit ff09156
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions vendor/ZKRevealingTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,29 @@ @implementation ZKRevealingTableViewCell

#pragma mark - Lifecycle

- (void)commonInit
{
self.direction = ZKRevealingTableViewCellDirectionBoth;
self.shouldBounce = YES;
self.pixelsToReveal = 0;

self._panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_pan:)];
self._panGesture.delegate = self;

[self addGestureRecognizer:self._panGesture];

self.contentView.backgroundColor = [UIColor clearColor];

UIView *backgroundView = [[UIView alloc] initWithFrame:self.contentView.frame];
backgroundView.backgroundColor = [UIColor clearColor];
self.backView = backgroundView;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.direction = ZKRevealingTableViewCellDirectionBoth;
self.shouldBounce = YES;
self.pixelsToReveal = 0;

self._panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_pan:)];
self._panGesture.delegate = self;

[self addGestureRecognizer:self._panGesture];

self.contentView.backgroundColor = [UIColor clearColor];

UIView *backgroundView = [[UIView alloc] initWithFrame:self.contentView.frame];
backgroundView.backgroundColor = [UIColor clearColor];
self.backView = backgroundView;
[self commonInit];
}
return self;
}
Expand All @@ -93,20 +98,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
self.direction = ZKRevealingTableViewCellDirectionBoth;
self.shouldBounce = YES;
self.pixelsToReveal = 0;

self._panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_pan:)];
self._panGesture.delegate = self;

[self addGestureRecognizer:self._panGesture];

self.contentView.backgroundColor = [UIColor clearColor];

UIView *backgroundView = [[UIView alloc] initWithFrame:self.contentView.frame];
backgroundView.backgroundColor = [UIColor clearColor];
self.backView = backgroundView;
[self commonInit];
}
return self;
}
Expand Down

0 comments on commit ff09156

Please sign in to comment.