Removing heightForRowAtIndexPath: iOs7 compatibility

In the new iOs8, if I don't implement the method heightForRowAtIndexPath

, the multi-line string will display with the correct height.
But, if I want to maintain backward compatibility with iOs7, I need a method heightForRowAtIndexPath

to be implemented ...
How to implement this only in iOs8?

+3


source to share


1 answer


You must use the define rule:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

      



This is how you should use it:

- (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;
}

      

+5


source







All Articles