ios 5 UISearchDisplayController crash

前端 未结 4 1842

I am implementing a UITableView with UISearchDisplayController in xcode 4.2. UITableView & UISearchDisplayController are created in StoryBoard. I set the Cell Identifier

4条回答
  •  死守一世寂寞
    2020-12-08 21:28

    Use [self.tableView dequeue...], not [tableView dequeue...].

    The cell you're trying to dequeue is linked to your primary view controller's tableView in the storyboard, NOT the searchDisplayController's newly created tableView (which has no cell identifiers linked to it). If you just message "tableView" then your dequeue message goes to the searchDisplayController's tableView since that's what was passed into the cellForRowAtIndexPath:... method.

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"CellId"];
    
        // do your thing
    
        return cell;
    }
    

提交回复
热议问题