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. ubuntu14.04安装pyspider

    sudo apt-get install libcurl4-openssl-dev libxml2-dev libxslt1-dev sudo atp-get install phantomjs 激活 ...

  2. 关于android api 23 +的权限问题

    Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, n ...

  3. EXCEL类型库的添加

    1. 创建新的C++工程 创建基于对话框的MFC程序 2. 添加库.添加Excel类库 在工程名上右键,选择“添加”—“类”(或者点击菜单栏的“项目”->“添加类”),选择“TypeLib中的M ...

  4. awk常见基本使用

    -F 指定分割符号 print 外层的引号必须是单引号 $n不能被解析 [root@bogon ~]# .txt a:b:c:d a1:b1:c1:d1 a2:b2:c2:d2 a_: :c:dddd ...

  5. (转)IE=EmulateIE7 标签的作用

    本文转载自:http://www.cnblogs.com/0000/archive/2009/11/01/1593851.html 对于 Web 开发人员来说,文本兼容性是一个要考虑的重要问题.Win ...

  6. 微信小程序生成太阳码

    微信小程序生成太阳码 https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=access_token 必须通过POST提交 而且参数 ...

  7. 第八章 JVM内存管理

    8.1 物理内存与虚拟内存 地址总线(连接处理器和RAM或处理器和寄存器的)的宽度影响了物理地址的索引范围,决定了处理器一次可以从寄存器或内存中获取多少个bit.同时决定了处理器最大的寻址空间,32位 ...

  8. mysql日期类型

    日期类型 DATE TIME DATETIME TIMESTAMP YEAR 作用:存储用户注册时间,文章发布时间,员工入职时间,出生时间,过期时间等 YEAR YYYY(1901/2155) DAT ...

  9. 解决word自动编号出现内容空格过大的问题

    选择你需要调整的段落.右键点击.选择“调整列表缩进” 然后在弹出的窗口中,第三行的“制表符”改成“空格”即可.或者空格都不需要可以改为“不特别标注”. 当编号超过10的时候,也会有空格太大的现象,这时 ...

  10. Python实现SSH连接远程服务器

    首先需要安装paramiko模块 #-*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import paramiko ssh = p ...