Similar to this previous question, I am having a problem with text alignment in my table cells. All the text is shifted up by a few pixels. I am not using custom cells; I am using regular UITableViewCell
s with the UITableViewCellStyleValue1
style, targeting iPhone OS 3.1. I would prefer a much simpler solution than the previous question's answer, especially since I'm not using custom cells. I'd also like to know exactly what the problem is, since that part of the question was never addressed.
Here's what it looks like on the simulator:
And on the device:
Edit: some more code as per request. (I'm building my table cells outside of cellForRowAtIndexPath.)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [cells objectAtIndex:[indexPath row]];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self loadCells];
[table reloadData];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)loadCells
{
cells = [[NSArray alloc] initWithObjects:[self aCell], [self bCell], nil];
}
- (UITableViewCell*)aCell
{
UITableViewCell* cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Foo"] autorelease];
cell.textLabel.text = @"A";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (UITableViewCell*)bCell
{
UITableViewCell* cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Foo"] autorelease];
cell.textLabel.text = @"B";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}