在新的iOs8中,如果我不实现heightForRowAtIndexPath
方法,多行的一行会以正确的高度显示。
但是,如果我想保持对 iOs7 的向后兼容性,我需要实现 heightForRowAtIndexPath
方法...
我如何才能仅在 iOs8 中实现它?
最佳答案
你应该使用定义规则:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
这里你应该如何使用它:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
return 100.0;//your custom height here
else
return UITableViewAutomaticDimension;
}
关于xcode - 删除 heightForRowAtIndexPath : compatibility with iOs7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26384823/