пожалуйста, посмотрите на мой код, моя метка ячейки не переносит текст.
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyCellIdentifier = @"MyCellIdentifier";
UITableViewCell *cell = (UITableViewCell*)[self.tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyCellIdentifier] autorelease];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell setClipsToBounds:NO];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
UILabel *label = [[UILabel alloc] init];
[label setBackgroundColor:[UIColor clearColor]];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:0];
[label setTextColor:[UIColor darkGrayColor]];
[label setShadowColor:[UIColor whiteColor]];
[label setShadowOffset:CGSizeMake(0, 1)];
[[cell contentView] addSubview:label];
[label release];
}
UILabel *froglabel = (UILabel *)cell;
NSUInteger row = [indexPath row];
CGSize textSize;
CGSize labelSize = { 100, 20000 };
[froglabel setText:genus];
[froglabel setFont:detailFont];
[froglabel setTextColor:[UIColor whiteColor]];
textSize = [[froglabel text] sizeWithFont:[self detailFont] constrainedToSize:labelSize lineBreakMode:UILineBreakModeWordWrap];
Высота представления таблицы для строки с индексом
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
CGSize textSize;
CGSize labelSize = { 300, 20000 }; // width and height of text area
textSize = [[self genus] sizeWithFont:[self detailFont] constrainedToSize:labelSize lineBreakMode:UILineBreakModeWordWrap];
NSLog(@"%i = height %f", row, textSize.height);
return textSize.height + 7;
break;
