6.10 UITableView
2015-06-10 18:45
405 查看
1,创建TableView
2,ResultTableViewController创建
3,UITabkeViewDelegate
@property(strong, nonatomic) UITableView *tableView; //表格视图 //1,创建tableview self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; //2,设置属性 self.tableView.dataSource = self; //2.1 设置数据源 self.tableView.rowHeight = 50; //2.2 设置固定行高 self.tableView.sectionIndexBackgroundColor = [UIColor grayColor]; //2.3 修改右侧指示栏背景颜色 self.tableView.sectionIndexTrackingBackgroundColor = [UIColor lightGrayColor]; //2.4 修改右侧指示栏背景颜色(点击时) self.tableView.sectionIndexColor = [UIColor blackColor]; //2.5 修改右侧指示栏标题颜色 self.tableView.delegate = self; //2.6 设置代理 //3,添加到父视图 [self.view addSubview:self.tableView];
2,ResultTableViewController创建
//4,创建收索控制器 ResultTableViewController *resultVC = [[ResultTableViewController alloc] init]; //4.1 创建结果控制器 self.searchController = [[UISearchController alloc]initWithSearchResultsController:resultVC]; //4.2 创建收索控制器 [self.searchController.searchBar sizeToFit]; //4.3 和tabview头部进行关联 self.tableView.tableHeaderView = self.searchController.searchBar; //4.4 自适应大小 self.definesPresentationContext = YES; //4.5 找到searchController正确的位置 self.searchController.dimsBackgroundDuringPresentation = NO; //4.6 呈现时取消背景 self.searchController.searchResultsUpdater = self; //4.7 设置searchResultsUpdater
3,UITabkeViewDelegate
#pragma mark - UITabkeViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //取消选中状态 [tableView deselectRowAtIndexPath:indexPath animated:YES]; } // 配置每一行cell的高度 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60; } // 配置区段的头部显示文本 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return self.keys[section]; } // 配置右侧指示栏标题列表 - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { NSLog(@"%@",_keys); return self.keys; }
相关文章推荐
- UGUI - 关于ScrollContent 和 Grid使用
- NSValue 封装成对象
- 6.9 UIScrollView
- 【Android】ContentValues的用法
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- Inverse = true,cascade=all
- 【Win 10 应用开发】打印UI元素
- 将UIImage转化成NSData在转化成NSString(将UIImage转化成Base64的字节流)
- Building and Testing with Gradle
- 异步模块定义AMD
- UIView与CALayer的区别,很详细
- oralce10g 安装dbvault出错OUI-25031
- 【MySql】Column count doesn't match value count at row 1 解决方法
- UVA11995:I Can Guess the Data Structure
- 得到UIImage的方法
- iOS UITableView的Section Footer添加按钮
- iOS UITableView的Section Footer添加按钮
- Android Bluetooth开发
- 详细解析BluetoothAdapter的详细api
- GRE的issue写作要求