title: Center Align text in UITableViewCell problem
body: <p>I'm kinda new to Objective-C and iPhone development and I've come across a problem when trying to center the text in a table cell.  I've searched google but the solutions are for an old SDK bug that has been fixed and these don't work for me.</p>
  
  <p>Some code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
      }
  
      cell.textLabel.text = @"Please center me";
      cell.textLabel.textAlignment = UITextAlignmentCenter;
      return cell;
  }
  </code></pre>
  
  <p>The above doesn't center the text.</p>
  
  <p>I have also tried the willDisplayCell method:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
      cell.textLabel.textAlignment = UITextAlignmentCenter;
  }
  </code></pre>
  
  <p>and I've tried some of the old posted solutions: </p>
  
  <pre><code>UILabel* label = [[[cell contentView] subviews] objectAtIndex:0];
  label.textAlignment = UITextAlignmentCenter;
  return cell;
  </code></pre>
  
  <p>None of these have any effect on the text alignment.  I have run out of idea's any help would be most appreciated.</p>
  
  <p>Cheers in advance.</p>