tableView のカスタムメイドのセルにある UITextView の高さを変更しようとしています。
「OverviewCell」は nib 内のこのカスタム セルの識別子であり、UITextView「postIntro」も nib にドラッグされます。
悲しいことに、高さは変化しません。スクロールした後でのみ高さが変化します。スクロールせずに表示されるセルは、ペン先からのデフォルトの高さです。
「postImage」の高さを変更しようとすると、同じ問題が発生します。
これは私のコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"OverviewCell";
OverviewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Post *post = [self.posts objectAtIndex:[indexPath row]];
if(!cell)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"OverviewCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[OverviewCell class]])
{
cell = (OverviewCell *)currentObject;
break;
}
}
}
[[cell postImage] setImage:[UIImage imageWithData:post.image]];
[[cell postTitle] setText:post.title];
[[cell postIntro] setText:post.intro];
// Resize the intro textview so the text fits in.
CGRect frame = cell.postImage.frame;
frame.size.height = 20; //cell.postIntro.contentSize.height;
[cell.postIntro setFrame:frame];
NSLog([NSString stringWithFormat:@"Height of textView on indexpath %i is set to %f", indexPath.row ,cell.postImage.frame.size.height]);
return cell;
}
私のコードへの他の提案は大歓迎です...