Implement heightForRowIndexPath: in iOS 7, but remove it in iOS 8 using compile time macro
I would like to implement new automatic resizing table view cells in iOS 8, while maintaining support heightForRowAtIndexPath:
in iOS 7. The problem is I need to remove the method override heightForRowAtIndexPath:
for iOS 8, but keep it in it for iOS 7. Is there some kind of time macro compilation which will do this?
+3
source to share
1 answer
You cannot use a compile-time macro because it is a runtime solution. Instead, you can simply return UITableViewAutomaticDimension
for iOS 8, and if not, return the computed height value.
#define IS_IOS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
-(CGFloat) tableView: (UITableView * ) tableView heightForRowAtIndexPath: (NSIndexPath * ) indexPath {
if (IS_IOS_8_OR_LATER)
return UITableViewAutomaticDimension;
else {
//Your iOS 7 code here.
}
}
+3
source to share