UITableView 的使用的小技巧
2015-09-05 17:24
507 查看
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];
// (UITableViewScrollPosition)某个Cell的位置
UITableView 学习推荐
/article/4991318.html
// 非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 学习推荐
/article/4991318.html
相关文章推荐
- 在IB中使用Auto Layout来添加UIScrollView
- Week1-2Quick Find
- UIKit框架类之窗口和视图架构介绍
- N-Queens
- java Map 按value值排序和按key值排序
- Arduino控制DTH11模块
- 2.2.4 Silhouette Enhancement (about transforming normal vectors) 轮廓增强(关于转换法向量)
- poj 1679 The Unique MST(次小生成树)
- IOS开发UI—transframe属性
- IOS开发UIGestureRecognizer的基本使用方式和代理
- FluentData,它是一个轻量级框架,关注性能和易用性。
- 快速上手如何使用FluentData
- 【dfs预处理+DLX】hdu 4069 Squiggly Sudoku
- 微型 ORM-FluentData 温故知新系列
- NgModelController: $setViewValue,$render,Formatter, Parser
- Arduino 9g舵机操作
- 条款20:宁以 pass-by-reference to const 替换 pass by value
- (iOS软件开发UI部分)UIButton基本使用
- deque及迭代器失效问题
- iPhone第四节:UIDatePicker、UIPickerView