我以编程方式创建了UITableView,现在我想向其中添加一个固定的 header 。
正如我下面的代码一样, header 也随着我的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 的同级兄弟- -您可以仅出于保留标题 View 和表 View 的目的而创建UIView。