ios7 UITableViewCell selectionStyle won't go back to blue

Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue.

From what I've read they changed the default selectionStyle to gray. But "Blue" is still an option in IB and UITableViewCellSelectionStyleBlue still exists. Checking out the new HIG, it doesn't look like they removed the blue and the "Settings" app still using blue cell selection.

I've tried setting the value in IB and in code, but no luck. Any ideas on what I need to do to get the blue selection style back?

asked Sep 13 at 19:45
DBD
4,12011544
 
   
   
I am unable to check it out right now, but in the cellForRowAtIndexPath method, it does not work to use the statement, cell.selectionStyle = UITableViewCellSelectionStyleBlue;? – for i in range awesomeSep 13 at 20:50
   
   
Just tested it out- it does not work. I will try to figure it out and get back to you if I can fix it – for i in range awesome Sep 13 at 21:12
   

add comment

2 Answers

There is only one selectionStyle in iOS7, to change you need to do this manually like below:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
....
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor blueColor];
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
....
return cell;
}
answered Sep 14 at 8:20
null
2,98211128
 
   
   
I was thinking about trying something like this- only problem is that blueColor is the ugliest possible shad of blue for this. If someone wants to actually use this in an app, then it would require using RGB combos for a better color – for i in range awesome Sep 14 at 16:38
   
   
So what I'm hearing is, blue as a default either no longer exists or isn't functioning properly. That was pretty much my conclusion too, but it seems awfully strange they wouldn't take it out of the UI or deprecate it if wasn't going to have a future. – DBD Sep 16 at 12:31
   
   
While not overly happy with this answer, this type of approach does seem to be the only which currently works (hopefully that will change soon). So I'm marking as the accepted answer. – DBD Sep 19 at 12:52
   
   
I agree, but what to do? it is not the best solution but apparently it is the only way to do the job, Apple has taken some actions in iOS7 made a lot of developers unhappy, for example you cannot add subview in UIActionSheet any more! this is really sad especially there is no workaround like your case and you should use another custom component rather than ActionSheet. – null Sep 19 at 15:24
   

add comment

Probably it could help you. I have my custom cell and to make it selected with needed color I have overwrite setHighlighted and setSelected now it's look like that

#define IOS_7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1 ? YES : NO)

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
[self changeSelectionColorForSelectedORHiglightedState:selected];
// Configure the view for the selected state
} - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[super setHighlighted:highlighted animated:animated];
[self changeSelectionColorForSelectedORHiglightedState:highlighted];
} - (void)changeSelectionColorForSelectedORHiglightedState:(BOOL)state
{
if (IOS_7) {
if (state) {
self.contentView.backgroundColor = [UIColor blueColor];
}
}
}
answered Sep 22 at 9:04
  add comment

ios7适配--uitableviewcell选中效果的更多相关文章

  1. ios7适配一些问题以及64位32位

    ios7适配一些问题(http://www.cocoachina.com/ios/20130703/6526.html) 1.iOS应用如何实现64位的支持 http://www.codeceo.co ...

  2. iOS7适配问题

    iOS7适配问题 2013-09-28 08:32:37     我来说两句      作者:冻僵的企鹅 收藏    我要投稿 iOS 7发布了,适配问题来了,开发者都忙起来了. 先记一个iOS7 的 ...

  3. 如何禁用ListView中的选中效果

    有的时候,我们希望ListView没有选中效果. 导致选中效果出现可能有两方面的原因: 1.每一行View自身可能有选中效果,可以将它的背景设置为透明 2.ListView有一个listSelecto ...

  4. iOS7 iOS8 UITableviewCell处于编辑状态,dismiss或者back崩溃

    今天在项目中遇到一个坑爹的 Crash , 在 iOS7 iOS8 UITableviewCell处于编辑状态,dismiss或者back崩溃  iOS9不会 原因:苹果的BUG代码 解决:在视图消失 ...

  5. 谈谈项目中遇到的各种iOS7适配问题

    由于我的项目要适配到iOS7.1, 而现在已经是9时代了,在实际工作中我也是遇到了各种奇葩的坑,所以我想尽快把遇到的iOS7适配问题和解决方案分享出来,以后这些东西可能就用处不大了. 1.字体问题 i ...

  6. 怎样创建TWaver 3D的轮廓选中效果

    在一般的游戏中.物体的选中效果会是这样: TWaver 3D中,物体的默认的选中效果一般都是一个方方正正的外框.在HTML5的Mono版本号中,TWaver提供了轮廓线样式的选中效果. 通过例如以下代 ...

  7. android实现对导航Tab设置下划线选中效果

    技术人员核心竞争力还是技术啊.努力提高各种实现效果.加油哦! 直接看效果.此linearLayout只有两个Button ,当选中Button1,Button1有个下划线选中效果.当选中Buton2, ...

  8. 利用this属性实现点击按钮变色.选中效果

    浏览器宿主的全局环境中,this指的是window对象. <script type="text/javascript"> console.log(this === wi ...

  9. 使用Vue.js实现列表选中效果

     实际项目中,我们会遇到很多类似的需求,一个列表,需要点击其中一条高亮显示.熟悉JQuery的同学说这个太简单了.可以给这个选中的element设置一个active的class.配合Css样式,让ac ...

随机推荐

  1. Weblogic配置SSl使用Https

    一 .可以开启自带的SSL连接 启动weblogic,进入左侧菜单,点击左侧的安全领域-->点击myrealm-->点击角色和策略-->点击服务器AdminServer 点击保存,w ...

  2. UOJ #188 Sanrd —— min_25筛

    题目:http://uoj.ac/problem/188 参考博客:https://www.cnblogs.com/cjoieryl/p/10149748.html 关键是枚举最小质因子...所以构造 ...

  3. Oracle记录(二) SQLPlus命令

    对于Oracle数据库操作主要使用的是命令行方式,而所有的命令都使用sqlplus完成,对于sqlplus有两种形式.就我个人而言,还是比较喜欢UNIX与Linux下的Oracle.呵呵 一种是dos ...

  4. install OS from usb

      https://unetbootin.github.io/ https://rufus.akeo.ie/

  5. 在PHP中对查询出得数据库数据进行json编码

    select.php <?php $con = mysql_connect("localhost","Thh","920920thh" ...

  6. git fatal: remote origin already exists. 报错解决

    在研究git的时候,随便输了个 git remote add origin xxx; 然后再真正add 远程仓库的时候,报了git fatal: remote origin already exist ...

  7. FIR数字信号滤波器

    数字滤波器 在信号处理领域中,对于信号处理的实时性.快速性的要求越来越高.而在许多信息处理过程中,如对信号的过滤.检测.预测等,都要广泛地用到滤波器. 其中数字滤波器具有稳定性高.精度高.设计灵活.实 ...

  8. 【转】JMeter 聚合报告之90% Line参数说明

    其实要说明这个参数的含义非常简单,可能你早就知道他的含义,但我对这个参数一直有误解,而且还一直以为是“真理”,原于一次面试,被问到了这个问题,所以引起我这个参数的重新认识. 先说说我错误的认识: 我一 ...

  9. tp5下通过composer实现日志记录功能

    tp5实现日志记录 1.安装 psr/log composer require psr/log 它的作用就是提供一套接口,实现正常的日志功能! 我们可以来细细的分析一下,LoggerInterface ...

  10. 优秀设计师必须知道哪些优秀的UI设计原则

    转自:http://www.gamelook.com.cn/2016/01/240359 界面清晰最重要 界面清晰是UI设计的第一步,要想让用户喜欢你设计的UI,首先必须让用户认可它.知道怎么样使用它 ...