搜索iOS8 + XCode6后不显示标题视图 [英] Header view is not display after search iOS8 + XCode6

查看:133
本文介绍了搜索iOS8 + XCode6后不显示标题视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有iOS7及以下版本的工作申请

我在表格中使用UISearchDisplayController进行搜索。

I have working application for iOS7 and below
I used UISearchDisplayController for search in table.

问题:

在iOS8中不显示搜索标题视图。

如下图所示。

Problem :
After search header view is not display in iOS8.
as display in below images.

搜索之前:

搜索后:



我尝试使用UISearchController但也有同样的问题
i使用此代码 link

我在TPSMastreViewController.m中添加以下代码

I add below code in TPSMastreViewController.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)section
在iOS8的情况下不调用


编辑:

我所理解的只是调用UITableViewDataSource委托,UITableViewDelegate没有。
请不要在ViewDidLoad中设置两个委托


问题:

1]这是UI更改吗?

2]任何人都有补丁,以便委托方法会强行调用。


I checked that delegate - (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section
is not called in the case of iOS8.
Edit :
What i understand is only UITableViewDataSource delegate is called, UITableViewDelegate did not.
Please not that i set both delegate in ViewDidLoad
Question :
1] Is it an UI change ?
2] Any one have patch so that delegate method will call forcefully.

推荐答案

我找到答案,所以写在这里它可以帮助其他人面临同样的问题

只需要添加委托heightForHeaderInSection,它将显示两个searchResultsController的标题视图UISearchController(iOS8)和searchResultsTableView用于UISearchDisplayController(iOS7)

just need to add delegate heightForHeaderInSection and it will show header view for both searchResultsController for UISearchController(iOS8) and searchResultsTableView for UISearchDisplayController(iOS7)

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

Add below code in TPSMastreViewController.m and it will solve problem.

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

我通过阅读这个问题找到了答案:)

在iOS 8中, UITableView heightForHeaderInSection不可选

I found my answer by reading this question :)
in iOS 8 UITableView heightForHeaderInSection is not optional

这篇关于搜索iOS8 + XCode6后不显示标题视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆