動的テーブルビューセルを構築しています。高さは、読み込まれたコンテンツに基づいて動的です。私はイメージビューの高さでハングアップしています。画像は現在、幅の100%の画像ビューにアスペクトフィルをロードします。テーブルビューセルのイメージがない場合、イメージビューが隠されている(高さが0である)ように、イメージビューに自動レイアウト制約を設定できますか?画像レイアウトが画像の高さに設定されるように自動レイアウト制約を設定できますか
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableViewTileCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tileCell"];
if (!cell)
{
[tableView registerNib:[UINib nibWithNibName:@"TableViewTileCell" bundle:nil] forCellReuseIdentifier:@"tileCell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"tileCell"];
}
cell.tileView.layer.borderColor = [UIColor blackColor].CGColor;
cell.tileView.layer.borderWidth = 1.0f;
[cell.contentView setBackgroundColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.0]];
NSString *url=[self.resultsArray[indexPath.row] valueForKey:@"imageURL"];
cell.tileTitle.text = [self.resultsArray[indexPath.row] valueForKey:@"title"];
cell.tileDate.text = [self.resultsArray[indexPath.row] valueForKey:@"date"];
cell.tileContent.text = [self.resultsArray[indexPath.row] valueForKey:@"summary"];
if(![url isEqualToString:@""]){ //If we got a url value back load the image
[cell.tileImageview setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
}
return cell;
}
'cellForRowAtIndexPath'を投稿できますか? – Adrian