UITableViewCellSelectionStyleBlue 不起作用 [英] UITableViewCellSelectionStyleBlue is not working

查看:23
本文介绍了UITableViewCellSelectionStyleBlue 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 UITableViewCellSelectionStyleBlue 作为单元格选择样式.但是无论我设置什么样式,它都只显示 UITableViewCellSelectionStylegray.我正在使用 Xcode 5.

I need to use UITableViewCellSelectionStyleBlue for the cell selection style. But whatever style I set it only displays UITableViewCellSelectionStylegray. I am using Xcode 5.

这是我的代码:

-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     static NSString *cellid = @"Table1";
     UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellid];
     if (cell==Nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
     }

     cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
     cell.selectionStyle =UITableViewCellSelectionStyleBlue;

     cell.imageView.image =[UIImage imageNamed:@"cellbgimg.png"] ;

     return cell;
}

推荐答案

我可以更改 UITableviewSelectionStyleBlue.请尝试以下代码:

i am able to change the UITableviewSelectionStyleBlue. Please try below code:

// take a view for the cell...

UIView *cellBg = [[UIView alloc] init];
cellBg.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // this RGB value for blue color
cellBg.layer.masksToBounds = YES;
Cell.selectedBackgroundView = cellBg;

这篇关于UITableViewCellSelectionStyleBlue 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆