cell 的自带的系统方法
2016-05-30 11:41
330 查看
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
// 开始的时候 tableView 的 cell 的selected 为0 当选中一个的时候 之前被选中的 cell 的selected 设置为0, 新选中的 cell 的selected设置为1;
[ super setSelected:selected animated:animated];
// - 例如下边的例子
1.设置 cell 的 textLabel 的 textColor(选中时候是红色的,非选中时候是灰色的)
self.textLabel.textColor = selected?[UIColor redColor] : [UIColor grayColor];
2. 设置 cell 中的某个控件的隐藏和显示(在选中 cell 时候显示,在非选中的状态 隐藏)
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
self.selectedIndicator.hidden = !selected;
}
// - 设置 cell 的 accessoryView
cell.accessoryView = [UIView alloc]init];
// - 返回 tableview 当前选中的 index
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
// 开始的时候 tableView 的 cell 的selected 为0 当选中一个的时候 之前被选中的 cell 的selected 设置为0, 新选中的 cell 的selected设置为1;
[ super setSelected:selected animated:animated];
// - 例如下边的例子
1.设置 cell 的 textLabel 的 textColor(选中时候是红色的,非选中时候是灰色的)
self.textLabel.textColor = selected?[UIColor redColor] : [UIColor grayColor];
2. 设置 cell 中的某个控件的隐藏和显示(在选中 cell 时候显示,在非选中的状态 隐藏)
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
self.selectedIndicator.hidden = !selected;
}
// - 设置 cell 的 accessoryView
cell.accessoryView = [UIView alloc]init];
// - 返回 tableview 当前选中的 index
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
相关文章推荐
- jQuery中的Ajax
- Xcode里面如何添加和配置pch文件??
- Android Studio 小技巧
- cmake之链接外部动态库
- 硬件加速引发的bug(关闭硬件加速即可解决)
- iOS UIWebView URL拦截
- 大数据资源网站
- 全局函数&数组
- 利用ida对程序的静态链接库进行处理
- Android自动开关机实现
- Android小知识——Vibrator使用示例
- java的四舍五入与保留位
- 设置 Linux 的 LD_LIBRARY_PATH 变量
- fatal error LNK1168: cannot open Debug/opreat.exe for writing
- Qt Creator中添加菜单栏实例
- 苹果提醒更新 修改
- zoj 3944
- 关于error:Cannot assign to 'self' outside of a method in the init family
- winform 中显示异步下载的图片
- Android