Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header view is not display after search iOS8 + XCode6

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

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

Before search : enter image description here

After search : enter image description here


I tried using UISearchController but also have same problem i used this code link

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;
}


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.
like image 808
Jageen Avatar asked Sep 03 '14 14:09

Jageen


1 Answers

I found answer so writing here it may help others facing same problem

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

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

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

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

like image 124
Jageen Avatar answered Oct 31 '22 12:10

Jageen