我想在 iOS 8 中实现新的自动调整大小的表格视图单元格,同时保持对heightForRowAtIndexPath:
iOS 7 的支持。问题是我必须删除heightForRowAtIndexPath:
iOS 8 的方法覆盖,但保留在 iOS 7 中。有吗使用一些编译时宏来完成这个?
问问题
480 次
1 回答
3
您不能使用编译时宏,因为这是运行时决定。相反,您可以只返回UITableViewAutomaticDimension
iOS 8,如果没有,则返回您计算的高度值。
#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.
}
}
于 2014-11-26T16:02:53.693 回答