1,在为uitableview设置分区标题时,需要用到两个方法。如下

#pragma mark setTitle

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

if (section == 0) {

return 50;

}

return 30;

}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

{

CGRect frameRect = CGRectMake(0, 0, 100, 40);

UILabel *label = [[[UILabel alloc] initWithFrame:frameRect] autorelease];

label.text=@"myTitle";

return label;

    

 

 

其中title若返回label时,一定要制定label的大小,不然显示不出来,因为label默认的大小是0. 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案