【发布时间】:2013-11-04 17:17:38
【问题描述】:
我在情节提要中有一个单元原型。所以我自定义了高度、子视图(标签和图像)。 但最终该单元格似乎并未用于 SearchDisplayController ...... 代码sn-p >>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
#warning Reusable cell not working for custom cell.
ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:itemCell];
if (cell == nil) {
cell = [[ItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:itemCell];
}
if (tableView == self.searchDisplayController.searchResultsTableView){
cell.itemLabel.text = [_filteredList objectAtIndex:indexPath.row];
cell.priceLabel.text = @"RM 7.00";
// TODO : Insert Image Here
} else {
cell.itemLabel.text = [_items objectAtIndex:indexPath.row];
cell.priceLabel.text = @"RM 7.00";
// TODO : Insert Image Here
}
return cell;}
我想不通。即使我使用 self.tableView 而不是 tableView 它也会显示类似的内容。
【问题讨论】:
-
您确定您的单元格标识符在您的故事板中设置正确吗? (与 itemCell 的值相同)
-
确定单元格标识符设置正确。我再次确认。
-
是单元格大小不对还是搜索后没有填入数据的问题?
-
它是单元格大小。搜索显示控制器的单元格不符合我的原型单元格大小
标签: ios iphone objective-c uitableview