xcode - 删除 heightForRowAtIndexPath : compatibility with iOs7

标签 xcode uitableview ios8 heightforrowatindexpath

在新的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/

相关文章:

iphone - Xcode——库的链接器警告——Debug-iphonesimulator 与 Debug-iphoneos

ios - 我可以将二进制形式的 iOS 应用程序传递给第三方应用程序商店进行代码签名吗?

ios - 如何使用作为委托(delegate)的自定义单元格将 UITextView 嵌入到 UITableViewCell 中?

ios - 使 NSString 中的某些单词成为粗体和可点击的标签

ios8 - 如何在 Xcode 6.1 中集成所有类型 iPhone 的启动屏幕?

xcode - 如何在构建期间以编程方式将文件作为资源包含在 Xcode 中?

ios - IBAction 按钮保持事件状态

ios - 从 AFNetworking 2.0 使用 JSON 加载 UITableView

iOS 13 移除 UIView 以模拟状态栏背景

Swift - 访问单例字典导致 EXC_BAD_ACCESS