繁体   English   中英

仅在iOS 7中点击表格单元格中的labeltext会消失

[英]labeltext in the tableview cell disappears when tapped on the cell only in iOS 7

这是我用来填充表格视图的代码:

- (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版本。 有解决此问题的指针吗?

在您的UITableViewCell

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM