Fix RETableViewBoolCell constraints on iOS 8

On iOS 8 UIKit adds own constraints to contentView, so removing all
contentView’s constraints causes problems when the cell
is displayed for the second time on the screen.
This commit is contained in:
Arkadiusz Holko
2014-06-21 18:10:39 +02:00
parent c190fbb4e3
commit be66559d59

View File

@@ -46,11 +46,7 @@
self.switchView.translatesAutoresizingMaskIntoConstraints = NO;
[self.switchView addTarget:self action:@selector(switchValueDidChange:) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.switchView];
}
- (void)cellWillAppear
{
[self.contentView removeConstraints:self.contentView.constraints];
CGFloat margin = (REUIKitIsFlatMode() && self.section.style.contentViewMargin <= 0) ? 15.0 : 10.0;
NSDictionary *metrics = @{@"margin": @(margin)};
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.switchView
@@ -62,7 +58,10 @@
constant:0]];
UISwitch *switchView = self.switchView;
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[switchView]-margin-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(switchView)]];
}
- (void)cellWillAppear
{
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.text = self.item.title;
self.switchView.on = self.item.value;