Created
November 12, 2014 11:21
-
-
Save priore/9c24dad864c70ebccfc3 to your computer and use it in GitHub Desktop.
fix the wrong value of sizeThatFits in a UITableViewCell
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
| // fix the wrong value of sizeThatFits in a UITableViewCell for iOS8 | |
| // UITableViewCell+iOS8.h | |
| #import <UIKit/UIKit.h> | |
| @interface UITableViewCell (iOS8) | |
| - (CGSize)sizeThatFitsiOS8:(CGSize)size; | |
| @end | |
| // UITableViewCell+iOS8.m | |
| #import "UITableViewCell+iOS8.h" | |
| @implementation UITableViewCell (iOS8) | |
| - (CGSize)sizeThatFitsiOS8:(CGSize)size | |
| { | |
| if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) { | |
| @try { | |
| [self setNeedsLayout]; | |
| [self layoutIfNeeded]; | |
| } | |
| @catch (NSException *exception) {} | |
| CGSize new_size = [self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; | |
| return new_size; | |
| } | |
| return [self sizeThatFits:size]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment