Last active
December 10, 2015 19:29
-
-
Save sonsongithub/4481617 to your computer and use it in GitHub Desktop.
Workaround, make UITableViewCell's indention work properly in iOS6 using Autolayout.
Cited from http://stackoverflow.com/a/13893146.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)awakeFromNib{ | |
| [super awakeFromNib]; | |
| for(NSLayoutConstraint *cellConstraint in self.constraints){ | |
| [self removeConstraint:cellConstraint]; | |
| id firstItem = cellConstraint.firstItem == self ? self.contentView : cellConstraint.firstItem; | |
| id seccondItem = cellConstraint.secondItem == self ? self.contentView : cellConstraint.secondItem; | |
| NSLayoutConstraint* contentViewConstraint = | |
| [NSLayoutConstraint constraintWithItem:firstItem | |
| attribute:cellConstraint.firstAttribute | |
| relatedBy:cellConstraint.relation | |
| toItem:seccondItem | |
| attribute:cellConstraint.secondAttribute | |
| multiplier:cellConstraint.multiplier | |
| constant:cellConstraint.constant]; | |
| [self.contentView addConstraint:contentViewConstraint]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment