UISearchDisplayController not correctly displaying custom cells

后端 未结 6 1521
抹茶落季
抹茶落季 2020-12-29 11:58

So I have a tableView that has sections and rows, and it uses a custom cell class. The custom cell has an image view and a few labels. The table view works fine, and the sea

6条回答
  •  执念已碎
    2020-12-29 12:48

    If you are using a UITableView in a UIViewController and you want to reuse a Cell Identifier you created in your StoryBoard for your searchDisplayController, try this:

    StoryBoard > UIViewController > Reference Outlets > link tableView to your UIViewController's .h file and call it something like tableView so you should have something like this:

    @property (strong, nonatomic) IBOutlet UITableView *tableView;
    

    So rather than doing it like this:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]
    }
    

    do this

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]
    }
    

提交回复
热议问题