0

I use custom cells in storyboard with height set to 57.

enter image description here

While searching in tableView,UISearchDisplayController returns my custom cell but the height is wrong.

enter image description here

Code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellReuseIdentifier = @"Cell";
CommemorativeItemCell *cell =[self.tableView dequeueReusableCellWithIdentifier:CellReuseIdentifier];

KmCell *kmCell=nil;

if(tableView==self.searchDisplayController.searchResultsTableView)
{
   kmCell=[self.filteredResult objectAtIndex:[indexPath row]];
}
else
{
    kmCell=[self.arr objectAtIndex:[indexPath row]];
}

// bla bla filling up and drawing labels...

return cell;
}

How to make the cells UISearchDisplayController returns to be of the same height? Thank you in advance.

NCFUSN
  • 1,624
  • 4
  • 28
  • 44

2 Answers2

2

Have you tried setting the height of the search results cells in viewDidLoad with

self.searchDisplayController.searchResultsTableView.rowHeight = 100;
adamweeks
  • 1,332
  • 2
  • 14
  • 21
1

Try this method this may help you!

You can return number as you want instead of 110. For example i am using 110.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 110;
}
Nagarjun
  • 6,557
  • 5
  • 33
  • 51