gpt4 book ai didi

uitableview - 如何禁用 UITableView 标题滚动?

转载 作者:行者123 更新时间:2023-12-04 15:04:07 34 4
gpt4 key购买 nike

我以编程方式创建了一个 UITableView,现在我想向它添加一个固定的标题。
正如我下面的代码一样,标题也随着我的 tableview 滚动。

    UILabel *label = [[[UILabel alloc] 
initWithFrame:CGRectMake(0, 0, 320, 28)] autorelease];

label.backgroundColor = [UIColor darkGrayColor];
label.font = [UIFont boldSystemFontOfSize:15];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.8];
label.textAlignment = UITextAlignmentLeft;
label.textColor = [UIColor whiteColor];
label.text = @"my header";

myTable.tableHeaderView = label;

是否有禁用标题滚动的功能?

谢谢

最佳答案

不,您需要将 View 更改为部分标题(当该部分可见时它将保留在表格 View 的顶部),或者您需要使标题 View 成为表格 View super View 中表格 View 的同级 - - 您可以创建一个 UIView 只是为了保存标题 View 和表格 View 。

关于uitableview - 如何禁用 UITableView 标题滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5058354/

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