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