diff --git a/prefs/HBStepperTableCell.m b/prefs/HBStepperTableCell.m index 339cd31..4f65a47 100644 --- a/prefs/HBStepperTableCell.m +++ b/prefs/HBStepperTableCell.m @@ -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]; @@ -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; } @@ -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