iOS tableView 使用笔记

禁止  tableView 回弹的方法   self.tableView.bounce = NO;

tableView 自适应高度方法

//写在Cell中

+ (CGFloat)cellHeight:(NSString *)contentString cellHeight1:(NSString *)titleString cellHeight:(NSString *)timeString;

//方法实现   

+ (CGFloat)cellHeight:(NSString *)nameString cellHeight1:(NSString *)addressString{

//计算cell高度

CGSize size  = CGSizeMake([UIScreen mainScreen].bounds.size.width, 0);

NSDictionary *dicContent = @{NSFontAttributeName: [UIFont systemFontOfSize:13]};

CGRect rect = [nameString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dicContent context:nil];

NSDictionary *dicTitleString = @{NSFontAttributeName:[UIFont systemFontOfSize:13]};

CGRect rectTitle = [addressString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dicTitleString context:nil];

return rect.size.height + rectTitle.size.height;

}

你可能感兴趣的:(iOS tableView 使用笔记)