IPhone 3.1 SDK device Aborts vertical alignment UITableViewCellStyleValue1 textLabel

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


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}


// Customize the appearance of table view cells.
- (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
+5
source share
2

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+4

. , , . UITableViewCellStyleDefault . , .

0

All Articles