这是我填充表格视图的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CellIdentifier = @"lcell~iphone";
} else
{
CellIdentifier = @"lcell";
}
lcell *stockCell = (lcell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (stockCell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
NSLog(@"CEll loaded1");
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
stockCell = (lcell *) currentObject;
NSLog(@"CEll loaded2");
break;
}
}
}
//Here setting the label text andg getting the label text of all cells correct even in ios7
stockCell.headerlabel.text= [[self.reserveArr objectAtIndex:indexPath.row] title];
NSLog(@"title %@",[[self.reserveArr objectAtIndex:indexPath.row] title]);
stockCell.headerlabel.tag=indexPath.row;
stockCell.headerlabel.numberOfLines = 1;
stockCell.headerlabel.adjustsFontSizeToFitWidth = YES;
stockCell.headerlabel.minimumFontSize = 0;
stockCell.headerlabel.numberOfLines=2;
return stockCell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setBackgroundColor:[UIColor clearColor]];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
当点击单元格时,标签或标签文本在 iOS7 中消失。它适用于所有其他 iOS 版本。有解决此问题的任何指示吗?