5

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.
Jageen
  • 6,345
  • 2
  • 37
  • 56

1 Answers1

5

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

Community
  • 1
  • 1
Jageen
  • 6,345
  • 2
  • 37
  • 56
  • If your header heights are always 20, then instead of implementing the delegate method just set the sectionHeaderHeight property of the UITableView. If you had say 1000 sections, it's faster for the table to multiply the height by 1000 to get a total height compared to calling your delegate method 1000 times. – SomeGuy Sep 21 '14 at 05:56
  • Thanks for suggestion but my problem is delegate method viewForHeaderInSection where no called, after search and after implementing this viewForHeaderInSection, its called. – Jageen Sep 21 '14 at 07:50
  • try this, it will also work (and perform better) [self.tableView setSectionHeaderHeight:20]; – SomeGuy Sep 21 '14 at 09:38
  • Nice find. Also faced this issue. – Robert J. Clegg Apr 16 '15 at 07:22