UITableView 的使用的小技巧
来源:互联网 发布:蛐蛐钢琴软件 编辑:程序博客网 时间:2024/05/21 07:09
1、tableView 设置 背景透明
// 非tableView的透明,设置后有Cell的部分不透明,无cell的部分透明(也可设置为类似一个半透明遮罩)
_selectTableV.backgroundView = nil;
_selectTableV.backgroundColor = RGBACOLOR(0, 0, 0, 0);
_selectTableV.opaque = NO;
2、默认选中某个Cell
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
// 默认选中首行
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[_selectTableV selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
// cell的选中时变化
UITableViewCell *cell = (UITableViewCell *)[_selectTableV cellForRowAtIndexPath:selectedIndexPath];
cell.textLabel.highlightedTextColor = Color_TabBlue;
}
3、cell选中无样式
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
4、cell禁止选中
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row > 2) {
return indexPath;
}
return nil;
}
5、NSIndexPath的创建
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
6、Cell刷新
(1)、刷新指定row或rows
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:selectedIndexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
(2)、刷新某个section内cell
[tableView reloadSections:section withRowAnimation:UITableViewRowAnimationNone];
7、tableView滚动到指定位置
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:row inSection:section];
[_tableV scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// 非tableView的透明,设置后有Cell的部分不透明,无cell的部分透明(也可设置为类似一个半透明遮罩)
_selectTableV.backgroundView = nil;
_selectTableV.backgroundColor = RGBACOLOR(0, 0, 0, 0);
_selectTableV.opaque = NO;
2、默认选中某个Cell
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
// 默认选中首行
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[_selectTableV selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
// cell的选中时变化
UITableViewCell *cell = (UITableViewCell *)[_selectTableV cellForRowAtIndexPath:selectedIndexPath];
cell.textLabel.highlightedTextColor = Color_TabBlue;
}
3、cell选中无样式
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
4、cell禁止选中
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row > 2) {
return indexPath;
}
return nil;
}
5、NSIndexPath的创建
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
6、Cell刷新
(1)、刷新指定row或rows
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:selectedIndexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
(2)、刷新某个section内cell
[tableView reloadSections:section withRowAnimation:UITableViewRowAnimationNone];
7、tableView滚动到指定位置
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:row inSection:section];
[_tableV scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// (UITableViewScrollPosition)某个Cell的位置
UITableView 学习推荐
http://www.cnblogs.com/smileEvday/archive/2012/06/28/tableView.html
0 0
- UITableView 的使用的小技巧
- 关于UITableView的小技巧
- UITableViewRowAction -- UITableView的一些小技巧
- UITableView 的使用小类别
- UITableView的使用规则和技巧等
- iOS UITableView(十一) tableView的几个小技巧
- UITableView的优化技巧
- UITableView的优化技巧
- UITableView的优化技巧
- UITableView的小知识
- UITableView常用小技巧
- UITableView 删除小技巧
- UITableView刷新小技巧
- 使用 Linux 的小技巧
- 使用CopyOnWriteArrayList的小技巧
- 笔记本电脑使用的小技巧
- Elipse的使用小技巧
- 使用约束的小技巧
- nodejs websocket 事件中传递的参数不对导致nodejs崩溃
- 面向对象(多态+接口实现)-第18天
- LBS基于位置服务
- 不懂得理解别人
- mac下为eclipse安装svn插件
- UITableView 的使用的小技巧
- iOS Simulator运行慢悠悠,但是APP的功能又很正常
- android app崩溃日志收集
- Low Memory Killer(低内存管理)
- 方法反射的基本操作
- C++和C语言混编
- websockete
- 操作系统文件管理
- 中国联通SGIP接口