NSString disconnects prematurely in UITableViewCell in version 3.0, but looks great in 3.1

I use UITableViewCellStyleValue2and UITableViewStyleGrouped.

Let's start with some code (it is not 100% complete, but I tried to include the code needed to hopefully decrypt what I am doing, and possibly do it wrong):

#define CELL_FONTSIZE 15.0f
CGSize textSizeValue2 = {207.0f, 9999.0f};

if ([value isEqual: CELL_4]) {
     CGSize   size = [cell4String sizeWithFont:[UIFont boldSystemFontOfSize:CELL_FONTSIZE] constrainedToSize:textSizeValue2 lineBreakMode:UILineBreakModeWordWrap];
     size.height += CELL_HEIGHT;          // top and bottom margin
     result = MAX(size.height, 44.0f);  // at least one row

For this particular cell, the result for height reaches 214 for both 3.0 and 3.1

Here's the code for the cell:

static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 0;
    cell.detailTextLabel.numberOfLines = 0;
    cell.clearsContextBeforeDrawing;

if ([value isEqual: CELL_4]) {
        cell.textLabel.text = @"About";
        cell.detailTextLabel.text = cell4String;

Basically, the same thing happens for 3.0 and 3.1, but when you start the application in simulator 3.0, the last line seems to be truncated if it cell.detailTextLabel.numberOfLineshas more than three lines of text. It is strange that the text is simply disabled, but the cell is drawn at the correct height of 3.0, there is just an empty space under the cell.

- , 3.0 3.1? , - Xcode, , -, 3.0, , , , - .

+1
3

, . , . , , , , , .

Xcode 3.1.3 3.0 SDK iPhone ( -). " " , , 3.0. .

+1

, . , , tableviewcell. . 20, , .

        UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:14.0];
    CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
    CGSize labelSize = [[detailValues objectAtIndex:indexPath.section] sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];

    labelHeight = labelSize.height + 20;
+1

, iOS5, , , - . , , .

adjustsFontSizeToFitWidth:NO

...

, , .

 CGRect frame = CGRectMake(0, 0, SCREEN_WIDTH, height);
 UIView *view = [[UIView alloc] initWithFrame:frame];
 cell.frame = frame;

, -

0

Source: https://habr.com/ru/post/1717191/


All Articles