gpt4 book ai didi

uitableview - 实现 heightForRowIndexPath : in iOS 7, 但在 iOS 8 中使用编译时宏删除它

转载 作者:行者123 更新时间:2023-12-01 23:52:00 25 4
gpt4 key购买 nike

我想在 iOS 8 中实现新的自动调整大小的表格 View 单元格,同时在 iOS 7 中保持对 heightForRowAtIndexPath: 的支持。问题是我必须删除方法覆盖 heightForRowAtIndexPath: 适用于 iOS 8,但适用于 iOS 7。是否有一些编译时宏可用于完成此操作?

最佳答案

您不能使用编译时宏,因为这是运行时决定的。相反,对于 iOS 8,您可以只返回 UITableViewAutomaticDimension,如果没有,则返回您计算出的高度值。

#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.
}

}

关于uitableview - 实现 heightForRowIndexPath : in iOS 7, 但在 iOS 8 中使用编译时宏删除它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25965039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com