Why does uitableview cell remain highlighted?
What would cause a tableview cell to remain highlighted after being touched? I click the cell and can see it stays highlighted as a detail view is pushed. Once the detail view is popped, the cell is still highlighted.
#######
In your didSelectRowAtIndexPath you need to call deselectRowAtIndexPath to deselect the cell.
So whatever else you are doing in didSelectRowAtIndexPath you just have it call deselectRowAtIndexPath as well.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Do some stuff when the row is selected
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
deselectRowAtIndexPath in my viewDidAppear, if select the row brings up a new view. – notnoop Dec 3 '09 at 15:59 -deselectRowAtIndexPath:animated: method on its tableView property from -viewDidAppear. However, if you have a table view in a UIViewController subclass, you should call -deselectRowAtIndexPath:animated: from -viewDidAppear yourself. :) – Daniel Tull Dec 4 '09 at 12:19 -viewWillAppear: that broke it. Adding a call to [super viewWillAppear:animated] got it working again. – Ben Challenor Jul 6 '11 at 9:38 UITableViewController's clearsSelectionOnViewWillAppear property is set to YES (which is the default), and you haven't prevented [super viewWillAppear] from being called. – Defragged Oct 31 '11 at 10:26 - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Unselect the selected row if any
NSIndexPath* selection = [self.tableView indexPathForSelectedRow];
if (selection) {
[self.tableView deselectRowAtIndexPath:selection animated:YES];
}
}
This way you have the animation of fading out the selection when you return to the controller, as it should be.
Taken from http://forums.macrumors.com/showthread.php?t=577677
http://stackoverflow.com/questions/1840614/why-does-uitableview-cell-remain-highlighted#comment1733845_1840757
Why does uitableview cell remain highlighted?的更多相关文章
- UITableView cell复用出错问题 页面滑动卡顿问题 & 各杂七杂八问题
UITableView 的cell 复用机制节省了内存,但是有时对于多变的自定义cell,重用时会出现界面出错(例如复用出错,出现cell混乱重影).滑动卡顿等问题,这里只简单敲下几点复用出错时的解决 ...
- UITableview cell 的多选
利用NSMutableDictionary key值 来改变cell的状态 -(void)createUI{ table = [[UITableView alloc]initWithFrame:CG ...
- UITableView cell中label自动换行和自定义label自动换行
换行的前提必须是有足够的高度 才能换 否则不显示超出部分 所以,在设置label换行的时候 要考虑cell的高度,cell的高度也要变化,废话不多说,来段代码: cell.label.text=[di ...
- UITableView Cell 弹簧动画效果
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath ...
- Swift - UIView,UItableView,Cell设置边框方法
// 设置边框的宽度 cell.layer.borderWidth = 1 // 设置边框的颜色 cell.layer.borderColor = UIColor.blackColor().CGCol ...
- UITableview cell中多个按钮
xib的 //不使用这种- (IBAction)button:(UIButton *)sender; //使用这种 @property (weak, nonatomic) IBOutlet UIBut ...
- UITableView cell 半透明效果,改变cell高度时背景不闪的解决方法
如果直接指定cell.backgroundColor = = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 ...
- 【iOS】UITableview cell 顶部空白的n种设置方法
我知道没人会主动设置这个东西,但是大家一定都遇到过这个问题,下面总结下可能是哪些情况: 1, self.automaticallyAdjustsScrollViewInsets = NO; 这个应该 ...
- IOS 7 UITableView cell lines不能靠左解决方法
添加一句:[UITableViewappearance].separatorInset=UIEdgeInsetsZero; 就可以解决啦.
随机推荐
- angular 指令@、=、&的用法和区别
1.指令作用域中的@ 作用是把当前属性作为字符串传递. html: <div ng-controller="MyCtrl"> <drink water=" ...
- 前端工程筹建NodeJs+gulp+bower
1.安装nodejs nodejs 官网下载安装文件 安装完成之后,在命令窗口执行,(显示nodejs版本) 和(显示npm版本)可以使用这两个命令查看是否安装成功: node -v npm -v 2 ...
- hdu2053
查找1-n中能整除n的数的个数. 如果是偶数的话,结果为0 奇数的话,结果为1 #include <stdio.h> int main(){ int i,cnt,n; while(~sca ...
- 1.2Android系统移植的主要工作
1.Android移植分为两部分:应用移植和系统移植: 2.应用移植:指将第四层的应用程序一直到某一特定硬件平台上. (1)为保证应用程序能在新的平台上正常运行,需要对源代码就行一些修改,因为硬件平台 ...
- mac 显示隐藏文件夹
在终端输入 defaults write com.apple.finder AppleShowAllFiles -boolean true;killall Finder即可
- (一)、NodeJS (转载)
NodeJS基础 ------ 转载自阿里巴巴 什么是NodeJS JS是脚本语言,脚本语言都需要一个解 ...
- c#使用DocX给word添加目录TOC
刚要做目录的时候,我就想DocX应该提供了这个方面的函数.于是我就在讨论区搜索,看看别人是怎么用的. 我搜索了catalog; catalogue; list; contents;,但是都没有和目录有 ...
- TFS build dotCover StyleCop
FS2010 – Customizing the Build Details View – Summary View http://blogs.msdn.com/b/jpricket/archive/ ...
- 火狐浏览器设置placeholder的时候记得改opacity
最近做项目的时候涉及到需要修改输入框的placeholder的字体颜色,我的CSS如下: ::-webkit-input-placeholder{ color: #c5c5c5;}::-moz-pla ...
- dispatchTouchEvent & onInterceptTouchEvent & onTouchEvent
http://www.cnblogs.com/jqyp/archive/2012/04/25/2469758.html dispatchTouchEvent 分发 onInterceptT ...