【发布时间】:2014-12-17 08:43:18
【问题描述】:
我是初级 iOS 程序员,我的问题是如何为 url 图像制作 facebook 或 tumblr 动态 tableview 单元格高度
我的服务器为图像提供 url 字符串,我的应用程序获取 json 字符串并显示来自UITableView 的图像。但是我的应用程序通过SDWebImage 处理UIImage,问题是uitableview 单元格高度没有改变。我的代码heightForRowAtindex委托方法是
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 112.0f;
} else {
NSMutableDictionary *userPostDataDic = [userPostContentData objectAtIndex:indexPath.row - 1];
JALabel *userPostContentLabel = [[JALabel alloc] initWithFrame:CGRectMake(80, 34, 220, 60)];
userPostContentLabel.numberOfLines = 3;
userPostContentLabel.text = [userPostDataDic valueForKey:@"home_board_text"];
[userPostContentLabel setFont:[UIFont fontWithName:@"AppleSDGothicNeo-Regular" size:13.0f]];
userPostContentLabel.textColor = [CommonViewController colorWithHexString:@"00A6F8"];
[userPostContentLabel setFrame:[CommonViewController getDynamicUILabelHeightWithLabel:userPostContentLabel contentString:[userPostDataDic valueForKey:@"home_board_text"]]];
if ([[userPostDataDic valueForKey:@"home_board_image"] isKindOfClass:[NSNull class]]) {
return [CommonViewController getDynamicUILabelHeightWithLabel:userPostContentLabel contentString:[userPostDataDic valueForKey:@"home_board_text"]].size.height + 34 + 50;
} else {
NSString *homeCellIdentifier = @"magazineTableViewCell";
HomeTableViewCell *homeTableCell = [tableView dequeueReusableCellWithIdentifier:homeCellIdentifier];
if (homeTableCell == nil) {
homeTableCell = [Face3Utils getViewFromNib:@"HomeTableViewXib" class:[HomeTableViewCell class]];
}
//UIImageView *forImageHeightImageView = [[UIImageView alloc] initWithFrame:CGRectMake(80, 34, 220, 100)];
[homeTableCell.userPostContentImageView sd_setImageWithURL:[NSURL URLWithString:[userPostDataDic valueForKey:@"home_board_image"]]
placeholderImage:[UIImage imageNamed:@"iu1.png"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
}];
homeTableCell.userPostContentImageView.image = [CommonViewController imageWithImage:homeTableCell.userPostContentImageView.image scaledToWidth:220.0f];
return [CommonViewController getDynamicUILabelHeightWithLabel:userPostContentLabel contentString:[userPostDataDic valueForKey:@"home_board_text"]].size.height + 34 + [homeTableCell.userPostContentImageView.image size].height + 50;
}
}
}
几乎 stackoverflow 的问题是如何为UILabel 制作动态表格视图单元格高度
但是要使用url图片动态UITableView单元格高度不存在请帮帮我
【问题讨论】:
标签: ios uitableview