Can someone explain the explanation of the following phenomenon?
As for the iPhone Device 3.1 SDK, I found that if it UITableViewCellhas a style UITableViewCellStyleValue1and it is detailTextLabel.textnot assigned, it textLabeldoes not appear in the center of the cell as expected.
One great caveat is that this only happens to me when I test the device - the iPhone Simulator 3.1 SDK displays cells correctly. In addition, this is not a problem when using the iPhone Device 3.0 SDK.
The following is a simple implementation of a subclass UITableViewControllerthat demonstrates the problem.
@implementation BuggyTableViewController
#pragma mark Table view methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"detailTextLabel.text unassigned";
break;
case 1:
cell.textLabel.text = @"detailTextLabel.text = @\"\"";
cell.detailTextLabel.text = @"";
break;
case 2:
cell.textLabel.text = @"detailTextLabel.text = @\"A\"";
cell.detailTextLabel.text = @"A";
break;
default:
break;
}
return cell;
}
@end
source
share