Sha*_*rog 5 iphone label alignment uitableview
与前一个问题类似,我在表格单元格中遇到文本对齐问题.所有文本都向上移动了几个像素.我没有使用自定义单元格; 我正在使用常规UITableViewCell的UITableViewCellStyleValue1风格,目标是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;
}
Run Code Online (Sandbox Code Playgroud)
我知道你的代码说你正在使用单元格样式UITableViewCellStyleValue1,但设备截图看起来真的很像UITableViewCellStyleSubtitle.
您应该设置一个值cell.detailTextLabel.text以确保获得预期的单元格样式.
在这方面,如果您不打算使用该detailTextLabel属性,您应该使用UITableViewCellStyleDefault.
| 归档时间: |
|
| 查看次数: |
1940 次 |
| 最近记录: |