Определение размера UILabel, чтобы соответствовать?

Как изменить следующий фрагмент (в табличном представлении: cellForRowAtIndexPath: UITableViewController метод) из рецепта «09a - PrefsTable» из главы 6 Поваренной книги разработчика iPhone:

if (row == 1) { 
    // Create a big word-wrapped UILabel 
    cell = [tableView dequeueReusableCellWithIdentifier:@"libertyCell"]; 
    if (!cell) { 
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"libertyCell"] autorelease]; 
        [cell addSubview:[[UILabel alloc] initWithFrame:CGRectMake(20.0f, 10.0f, 280.0f, 330.0f)]]; 
    } 
    UILabel *sv = [[cell subviews] lastObject]; 
    sv.text =  @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation."; 
    sv.textAlignment = UITextAlignmentCenter; 
    sv.lineBreakMode = UILineBreakModeWordWrap; 
    sv.numberOfLines = 9999; 
    return cell; 
} 

... чтобы размер подпредставления "sv" UILabel и ячейки "UITableViewCell" был достаточно велик, чтобы вместить текст (и работать с большим или меньшим количеством текста и другими типами выравнивания текста)? Я посмотрел на UILabel textRectForBounds: limitedToNumberOfLines: метод, но в документации говорится, что он не должен вызываться напрямую (и должен быть только переопределен). Я экспериментировал с методом UIView sizeToFit, но безуспешно.

Обновить: Я задал новый вопрос о моей проблеме с NSString -sizeWithFont: forWidth: lineBreakMode: метод.

Ответы на вопрос(9)

Ваш ответ на вопрос