5

我有适用于iOS7和以下版本的工作应用程序
我在表中使用UISearchDisplayController进行搜索。
搜索后不显示标题视图iOS8 + XCode6

问题:
后搜索标题视图中未显示iOS8上。
显示在下图中。

之前搜索: enter image description here

搜索后: enter image description here


我尝试使用UISearchController也有同样的问题 我用这个代码 link

我添加下面的代码在T中PSMastreViewController.m

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    UIView *v = [[UIView alloc] init]; 
    v.backgroundColor = [UIColor greenColor]; 
    return v; 
} 


我检查了委托 - (UIView的*)的tableView:(UITableView的*)的tableView
viewForHeaderInSection:(NSInteger的)部分
没有在iOS8上的情况下调用。
编辑:
我的理解是只有UITableViewDataSource委托被调用,UITableViewDelegate没有。
请不是我在viewDidLoad中同时设置委托
问:
1]它是一个UI的变化?
2]任何人都有补丁,以便委托方法将强制调用。

回答

5

我找到答案这么写,这可以帮助其他面临同样问题

只需要添加委托heightForHeaderInSection,它会显示两个searchResultsController为UISearchController程序(iOS 8)和searchResultsTableView为UISearchDisplayController头视图(iOS7 )

在TPSMastreViewController.m中添加以下代码,它将解决问题。

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    return 20; 
} 

我通过阅读这个问题:)
in iOS 8 UITableView heightForHeaderInSection is not optional

+0

如果你的头的高度总是20,然后,而不是仅仅实现设定的UITableView的sectionHeaderHeight财产委托方法找到我的答案。如果您有1000个分区,那么表格将高度乘以1000以获得总高度的速度要快于调用委托方法1000次。 – SomeGuy 2014-09-21 05:56:18

+0

感谢您的建议,但我的问题是委托方法viewForHeaderInSection哪里没有调用,搜索后,实现了这个viewForHeaderInSection后,其调用。 – Jageen 2014-09-21 07:50:37

+0

试试这个,它也会工作(并且表现更好)[self。tableView setSectionHeaderHeight:20]; – SomeGuy 2014-09-21 09:38:02

相关问题