gpt4 book ai didi

iPhone分组uitableview标题字体样式

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

我在更改分组 uitableview 的节标题时遇到问题。我已经尝试了一切。我想知道这是模拟器的错误还是什么?我正在运行最新版本的 xcode 并正在为 iPad 进行开发。

这是我的表格 View 标题代码

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

UILabel *label = [[[UILabel alloc] init] autorelease];
label.frame = CGRectMake(20, 6, 300, 30);
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor grayColor];
label.shadowOffset = CGSizeMake(0.0, 1.0);
label.font = [UIFont boldSystemFontOfSize:14];
label.text = @"hello"; //sectionHeader;

return label;

}

当我编译时,它只是显示没有标题。我也尝试在这里添加一个 View ,按照下面的代码

UIView *sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
sectionView.backgroundColor = [UIColor redColor];
[sectionView autorelease];
[sectionView addSubview:label];
return sectionView;

我做错了什么吗?

最佳答案

来自the documentation :

[tableView:viewForHeaderInSection:] only works correctly when tableView:heightForHeaderInSection: is also implemented.

关于iPhone分组uitableview标题字体样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3590601/

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