【发布时间】:2011-06-17 12:51:05
【问题描述】:
我在 UITableView 的标题上有 UISearchBar,我想在 UISearchBar 上方添加 UILabel。 UILabel 首次隐藏,当用户向下滚动 TableView 时,会出现 UILabel。它是在 WhatsApp 的“联系人”选项卡中完成的。
最好的方法是什么?任何帮助将不胜感激。
问候
【问题讨论】:
标签: iphone ios uitableview uilabel uisearchbar
我在 UITableView 的标题上有 UISearchBar,我想在 UISearchBar 上方添加 UILabel。 UILabel 首次隐藏,当用户向下滚动 TableView 时,会出现 UILabel。它是在 WhatsApp 的“联系人”选项卡中完成的。
最好的方法是什么?任何帮助将不胜感激。
问候
【问题讨论】:
标签: iphone ios uitableview uilabel uisearchbar
一种方法是在 UIView 中添加 UILabel、UISearchBar 和 UITableView。
否则,在第一行添加 UILabel,在第二行添加搜索栏,然后继续...
【讨论】:
目前无法测试,但我认为:
theHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - HEADER_HEIGHT, 320, HEADER_HEIGHT)]
headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, HEADER_HEIGHT)];
headerLabel.textAlignment = UITextAlignmentCenter;
另外不要忘记将子视图添加到标题中:
[theHeader addSubview:headerLabel] 并在CGRectMake 内或定义的(例如#define HEADER_HEIGHT 52.0f)内为您的标题设置高度
让我知道它是否有效!
【讨论】: