与之前的问题类似,我在我的表格单元格中遇到了文本对齐问题。所有文本都向上移动了几个像素。我没有使用自定义单元格;我正在使用带有
这是模拟器上的效果: 模拟器 http://www.shaggyfrog.com/junk/table-cell-label-misalignment-simulator.png 这是设备上的效果: 设备 http://www.shaggyfrog.com/junk/table-cell-label-misalignment-device.png 编辑:根据请求提供更多代码。(我正在
UITableViewCellStyleValue1
样式的普通UITableViewCell
,针对iPhone OS 3.1。我希望得到比之前问题的答案更简单的解决方案,特别是因为我没有使用自定义单元格。我还想知道问题的确切原因,因为该问题的这一部分从未得到解决。这是模拟器上的效果: 模拟器 http://www.shaggyfrog.com/junk/table-cell-label-misalignment-simulator.png 这是设备上的效果: 设备 http://www.shaggyfrog.com/junk/table-cell-label-misalignment-device.png 编辑:根据请求提供更多代码。(我正在
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;
}
cellForRowAtIndexPath
的代码吗?我以前使用过UITableViewCellStyleValue1
,但从未遇到过这个问题。 - Ben S