我有UITableViewCell
单元格style = UITableViewCellStyleValue1
(这种样式用于view controllers
我在项目中使用的所有其他样式)。cell identifiers
根据其他 SO 帖子的建议,我已经仔细检查了我的故事板中的内容。我仍然得到detailTextLabel
零。还有什么我做错了吗?我观察到单元总是被重用,即永远不会执行分配语句。那么,如何让我UITableViewCell
的对象的样式来验证重复使用的单元格是否遵循相同的样式?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellForDevice";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
NSLog(@"reuse ID : %@",cell.reuseIdentifier);
// Configure the cell...
NSArray* row = [self.listOfItems objectAtIndex:indexPath.row];
NSString* str = [row objectAtIndex:0];
NSString* status = [row objectAtIndex:1];
cell.textLabel.text = str;
if(cell.detailTextLabel == nil)
NSLog(@"detailTextLabel nil");//didn't expect this would execute
cell.detailTextLabel.text = status;
cell.detailTextLabel.backgroundColor = [UIColor greenColor];
NSLog(@"status %@ ",status);
return cell;
}