Implement heightForRowIndexPath: in iOS 7, but remove it in iOS 8 using compile-time macro

▼魔方 西西 提交于 2019-12-06 02:27:46

You can not use a compile time macro because this is a run time decision. Instead, you can just return UITableViewAutomaticDimension for iOS 8 and if not, return your calculated 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.
  }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!