カスタム UITableViewCell を作成し、 xib からロードしているため、テキストが動的になる可能性があるため、 Custom UITableViewCell dynamic に存在する UILabel の高さが必要です。
カスタムUITableViewCellのコードは
#import <UIKit/UIKit.h>
@interface NarrativeCell : UITableViewCell
@property(nonatomic,retain) IBOutlet UILabel *noteTitle;
@property(nonatomic,retain) IBOutlet UILabel *noteDate;
@property(nonatomic,retain) IBOutlet UILabel *noteDesc;
@property(nonatomic,retain) IBOutlet UIImageView *sideImage;
@property(nonatomic,retain) IBOutlet UIButton *imageButton;
@property(nonatomic,retain) IBOutlet UIButton *audioStartButton;
@property(nonatomic,retain) IBOutlet UIButton *audioStopButton;
@end
ここにコードがあります
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"NarrativeCell";
NarrativeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
NSLog(@"New Cell Made");
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"NarrativeCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[NarrativeCell class]])
{
cell = (NarrativeCell *)currentObject;
break;
}
}
}
Narratives *n=(Narratives *)[tableArray objectAtIndex:indexPath.row];
CGRect newFrame = cell.noteDesc.frame;
NSLog(@"old %f",newFrame.size.height);
newFrame.size.height = expectedLabelSize.height;
//yourLabel.frame = newFrame;
NSLog(@"new %f",newFrame.size.height);
newFrame.size.height = expectedLabelSize.height;
[cell.noteDesc setFrame:newFrame];
[cell.noteDesc setNumberOfLines:0];
[cell.noteDesc setText:n.cfcnl_note];
return cell;
}
残念ながら、高さのサイズを変更することはできません
[cell.noteDesc setFrame:newFrame];
nibファイルからロードしているため、UILabelの現在のカスタムUITableViewCell(nibで作成)の高さを動的に変更するにはどうすればよいか教えてください。
/////////編集
ここで old new の出力を参照してください old 21.000000 new 42.000000