Skip to content

Commit

Permalink
[HBStepperTableCell] we should be setting this as the accessory view
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Dec 4, 2015
1 parent e68e2d5 commit ab5e347
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions prefs/HBStepperTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ @implementation HBStepperTableCell

@dynamic control;

#pragma mark - UITableViewCell
#pragma mark - PSTableCell

- (void)prepareForReuse {
[super prepareForReuse];
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier];

self.control.value = 0;
self.control.minimumValue = 0;
self.control.maximumValue = 100;
}
if (self) {
self.accessoryView = self.control;
}

#pragma mark - PSTableCell
return self;
}

- (void)refreshCellContentsWithSpecifier:(PSSpecifier *)specifier {
[super refreshCellContentsWithSpecifier:specifier];
Expand All @@ -41,16 +41,8 @@ - (void)setCellEnabled:(BOOL)cellEnabled {
#pragma mark - PSControlTableCell

- (UIStepper *)newControl {
UIStepper *stepper = [[UIStepper alloc] init];
stepper.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectZero];
stepper.continuous = NO;
stepper.center = CGPointMake(stepper.center.x, self.frame.size.height / 2);

// i assume this is what i'm meant to do?
CGRect frame = stepper.frame;
frame.origin.x = self.contentView.frame.size.width - frame.size.width - 15.f;
stepper.frame = frame;

return stepper;
}

Expand All @@ -77,4 +69,14 @@ - (void)_updateLabel {
[self setNeedsLayout];
}

#pragma mark - UITableViewCell

- (void)prepareForReuse {
[super prepareForReuse];

self.control.value = 0;
self.control.minimumValue = 0;
self.control.maximumValue = 100;
}

@end

0 comments on commit ab5e347

Please sign in to comment.