mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-01-12 22:51:51 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user