我使用xib創建自定義單元格。我想顯示一個標籤,取決於標籤文本。如何增加行高以及標籤高度?如何增加iPhone的行高?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
customCell *cell=(customCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[NSBundle mainBundle]loadNibNamed:@"customCell" owner:self options:nil]objectAtIndex:0];
UIImage *userimage=[self getUserImage:[userimageURLS objectAtIndex:indexPath.row]];
cell.userImageViewIv.autoresizesSubviews=YES;
cell.userImageViewIv.image=userimage;
cell.userNameLbl.text=[UserName objectAtIndex:indexPath.row];
cell.commenttxtlbl.text=[postText objectAtIndex:indexPath.row];
NSLog(@"cell created");
}
return cell;
}
變量posttext數組不是靜態的。它是動態的。
我已經使用了上面的代碼。
你在heightForCell中寫了什麼? – Nirmalsinh
如果> = iso7參考 ** - tableView:estimatedHeightForRowAtIndexPath:** https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference。html#// apple_ref/occ/intfm/UITableViewDelegate/tableView:estimatedHeightForRowAtIndexPath: – CoolMonster