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. 关于Apache Phoenix和Cloudera结合

    1. 安装: phoenix的官网最新版4.13.2是有parcle版本的,并不需要从cloudera的labs(实验室)中下载.安装完成后,可以运行一下phoenix的shell来简单验证一下:/o ...

  2. 【转】学习使用Jmeter做压力测试(二)--压力测试的实施

    JMeter测试步骤: 1.建立测试计划 2.添加线程组 3.添加HTTP请求 4.增加监听器 5.执行测试计划 6.根据JMeter提供的报告分析结果 一.目标 测试访问目标服务器网站首页的每秒查询 ...

  3. getpass密码隐藏

    使用getpass模块对输入的字符进行隐藏输入 #-*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import getpass u ...

  4. java-虚拟机-索引

    底层 JVM之堆内存(年经代,老年代) Java内存泄露的理解与解决 内存溢出和内存泄漏的区别.产生原因以及解决方案 JVM内容梳理 Jvm的体系结构

  5. angular结合echarts创建图表

    原理: 利用angularjs中的指令(directive)将echarts封装. 步骤: 1.封装函数: app.directive('line', function() { return { re ...

  6. 最长上升子序列(LIS)

    最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS.排序+LCS算法 以及 DP算法就忽略了,这两个太容易理解了. 假设存在一个序列d[1..9] = ...

  7. MySQL与SQLServer的update left join语法区别

    需求: 表A 字段 A_ID, A_NAME, B_ID 表B 字段 B_ID, B_NAME 需求把A的所有A_NAME更新为相应的B的 B_NAME. mysql做法: UPDATE A LEFT ...

  8. CSS鼠标手势大全

    实例: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. ...

  9. 局域网内的一些计算机可以ping通 有些ping不同

    如何查看.添加.修改.删除电脑内部路由_百度经验https://jingyan.baidu.com/article/77b8dc7fc611626174eab6cb.html

  10. 从官网下载jdk1.6 1.7

    Oracle Java Archive | Oracle Technology Network | Oraclehttp://www.oracle.com/technetwork/java/javas ...