【发布时间】:2014-01-15 17:41:26
【问题描述】:
如何在一个 TableHeaderView 中添加两个简单的 UILabel 并保留 iOS7 中搜索显示控制器的默认搜索栏行为?
或者,视觉上:
为什么会有这段代码:
UIView *tableHeadView = self.tableView.tableHeaderView;
UILabel *tableHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 36, 320, 30)];
[tableHeaderLabel setTextAlignment:NSTextAlignmentCenter];
tableHeaderLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:18];
tableHeaderLabel.text = @"Questions"
UILabel *tableHeaderPrononce = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 320, 30)];
[tableHeaderPrononce setTextAlignment:NSTextAlignmentCenter];
tableHeaderPrononce.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:15];
tableHeaderPrononce.text = @"test test test test";
[tableHeadView addSubview:tableHeaderLabel];
[tableHeadView addSubview:tableHeaderPrononce];
添加到 UITableViewController viewDidLoad 事件(其中包含 UISearchDisplayerController)
在 iOS6 中给出了这个可爱的结果:
而在 iOS7 中这个可怕的可怕结果:
行为: 在正常模式下,我添加的 UILabel 不会显示。当搜索处于活动状态时,UILabels 突然出现在表格单元格的顶部并且不会滚动
此外,我在 iOS 7 中搜索时遇到了崩溃,这在 iOS6 上从未发生过。可能与这段代码无关,但我应该提到这一点。
我尽我所能找到解决此问题的方法,但总是有其他东西中断或消失(主要是 UISearchBar)。
帮助
【问题讨论】:
-
如果有任何方法可以链接到 github 上的项目,我会为你看看这两个问题。
-
它不在 git 上,但所有相关代码都在这里
标签: ios objective-c ios7 uitableview