How to set UITableViewCellStyleSubtitle textAlignment for center in iPhone iOS4?

From upgraded Xcode to version 3.2.3 with iPhone SDK 4, my code no longer works.

I have a default cell with a style UITableViewCellStyleSubtitleand you want to set textAlignmentfrom textLabeland detailTextLabelto center, but nothing happens. The same code that was used previously no longer works. The UITableViewCellStyleDefaultcenter alignment still works.

Does anyone know how to solve this? I do not want to use a custom cell just really.

+2
source share
3 answers

, , , , . , :

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    cell.textLabel.backgroundColor = [UIColor orangeColor];
}

, , . UITableViewCell.

UITableViewCellStyleSubtitle :

. iPod .

+4

, :

-- (void) updateCenteringForTextLabelInCell:(UITableViewCell*)cell {

    UILabel* label = cell.textLabel;

    label.frame = CGRectMake(label.frame.origin.x, label.frame.origin.y, cell.contentView.frame.size.width, label.frame.size.height);

}


-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

// do your usual

// call the helper method 

[self performSelector:@selector(updateCenteringForTextLabelInCell:) withObject:cell afterDelay:0.05];

}
+1

, , Apple 23 2010 :

" layoutSubviews ".

0

All Articles