UITableView 使用 selectRowAtIndexPath 不能默认选中cell的问题
来源:互联网 发布:linux开机选择系统 编辑:程序博客网 时间:2024/05/22 02:06
http://stackoverflow.com/questions/23025120/selectrowatindexpath-from-another-uiviewcontroller-not-working
按照常理,以及文档说明,函数
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
就是做的这个事,用来人工选中 cell,但是在UITableViewController中确实无效。
但是发现无效。通过上面的帖子,发现是有个UITableViewController 的属性
clearsSelectionOnViewWillAppear
需要设置为NO,这个默认为 YES。导致每次willAppear的时候,会去清理select的数据。解释如下:
When the table view is about to appear the first time it’s loaded, the table-view controller reloads the table view’s data. It also clears its selection (with or without animation, depending on the request) every time the table view is displayed. The UITableViewController class implements this in the superclass method viewWillAppear:. You can disable this behavior by changing the value in the clearsSelectionOnViewWillAppear property.
修改成如下代码就好了:
- (void)viewDidLoad{ [super viewDidLoad]; self.clearsSelectionOnViewWillAppear = NO;}
1 1
- UITableView 使用 selectRowAtIndexPath 不能默认选中cell的问题
- UITableView使用selectRowAtIndexPath不能默认选中cell的问题
- UiTableView 默认选中一个cell
- UITableView默认选中一个Cell
- UITableView默认选中第一个cell
- UITableView默认选中第一个cell
- UITableView默认选中第一行,以及获取当前选中的cell
- 默认选中UITableView的一行
- iOS Uitableview的cell的选中样式
- iOS Uitableview的cell的选中样式
- Swift3.0 UITableView/UICollectionView默认选中某个 cell
- IOS开发相关07--UITableView默认选中第一个cell
- 关闭UITableView cell的被选中效果
- UITableView获取当前选中的cell
- UITableView取消选中的cell方法
- 去掉UITableView的Cell选中状态
- 设置UITableView的cell能否被选中
- uitableview中设置某个cell不能选中,其他可以选
- Linux: /dev/random , /dev/urandom
- hdu5289 2015多校联合第一场1002 Assignment
- 连接查询,条件在on和where后面的区别
- 使用Profiler工具分析内存占用情况
- 美图内网漫游(沦陷大量内部系统、内部服务器权限、企业架构、企业邮箱等敏感信息) - rsync,fastcgi
- UITableView 使用 selectRowAtIndexPath 不能默认选中cell的问题
- JAVA最多支持多少个线程
- Model绑定机制3:集合+字典
- 程序中三种不同的出错处理方式比较
- POJ 1018 Communication System
- C++构造函数
- [LeetCode]Course Schedule
- 一元二次方程求解
- Android开发实例透明效果设置方法