关于tableView样式为UITableViewStyleGrouped间距的设置
2014-07-08 09:34
585 查看
tableView的Grouped样式,是在每个section之间有固定的高度,像系统的设置界面
- (void)viewDidLoad { [super viewDidLoad]; _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 20, 320, 460) style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; [self.view addSubview:_tableView]; _dataArray1 = @[@"海贼王",@"火影忍者"]; _dataArray2 = @[@"穿越火线",@"DOTA2"]; } #pragma mark - tableViewDelegate //如果不设置section的高度是有默认的值 //-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section //{ // return 12;//如果设置section的header高度,不设置footer高度,footer默认等于header高度 //} //-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section //{ // return 12;//这个方法不写,或者return 0跟return 12的效果一样 // return 0.01;//把高度设置很小,效果可以看成footer的高度等于0 //} #pragma mark - tableViewDataSource -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(section == 0) { return _dataArray1.count; } return _dataArray2.count; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * CellIdentifier = @"Cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } if(indexPath.section == 0) { cell.textLabel.text = _dataArray1[indexPath.row]; } else { cell.textLabel.text = _dataArray2[indexPath.row]; } return cell; }
相关文章推荐
- 关于tableView group样式 时设置 cell的width 宽度
- iOS开发-进阶:设置group类型tableview的section间距
- IOS-UITableViewStyle设置Group、Plain问题
- 解决iOS7中,tableView设置UITableViewStyleGrouped后的section之间空余问题
- 使 UITableViewStylePlain Style 的TableView header 不浮动,像Group Style 那样固定,跟随Tableview 滚动,而不会停在顶端。
- 解决iOS7中,tableView设置UITableViewStyleGrouped后的section之间空余问题
- UITableViewStylePlain与UITableViewStyleGroup样式的对比
- iOS中使用的tableview为group形式时如何设置不同sections的间距
- 第16月第25天 tableView设置UITableViewStyleGrouped顶部有空余高度
- IOS-UITableViewStyle设置Group、Plain问题
- 关于设置 UITableView 的 tableHeaderView为使用了 SnapKit 约束的自定义 view 时出现的 BUG 的处理
- IOS-UITableViewStyle设置Group、Plain问题
- tableView设置UITableViewStyleGrouped顶部有空余高度
- UITableViewStyle设置Group、Plain问题
- 关于UITableView 多组组间距的设置
- iOS中使用的tableview为group形式时如何设置不同sections的间距
- 在Fragment 里面关于ViewPagerIndicator设置样式(Style)不起作用
- 关于android 动态设置view 样式 问题(默认style)
- iOS UITableView 设置分割线样式
- ios7设置group类型tableview的section间距