gpt4 book ai didi

iphone - 为表中的每个部分添加标题

转载 作者:行者123 更新时间:2023-12-03 20:25:24 25 4
gpt4 key购买 nike

我的表格 View 中有 4 个部分,如何为我正在编写以下代码的每个部分添加标题,但它不起作用。

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:   (NSInteger)section { 
if (section == 0)
return @"Tasks";

if (section == 1)
return @"Appointments";

if (section == 2)
return @"Activities";

if (section == 3)
return @"Inactivities";
}

最佳答案

使用以下代码..

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

UILabel *lbl = [[UILabel alloc] init];
[lbl setBackgroundColor:[UIColor clearColor]];
[lbl setFont:[UIFont fontWithName:@"Arial" size:17]];
[lbl setTextColor:BROWN];
switch (section)
{
case 0:
lbl.text = @" Name";
break;
case 1:
lbl.text = @" Quantity";
break;
case 2:
lbl.text = @" Amount";
break;
}

return lbl;
}

关于iphone - 为表中的每个部分添加标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9374696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com