我正在使用 Storyboard。我有一个带有一个原型(prototype)单元格的 UITableView。此单元格的样式为“副标题”。我已经从单元格添加了一个 segue 到详细 View 。因此,当用户点击一个单元格时,它将打开相应的编辑器……这一切都很好。
现在我添加了一个 UISearchDisplayController 和一个 UISearchBar,实现了委托(delegate)。效果很好。
但在搜索结果表中,单元格的样式为“默认”且不可点击。我必须做什么才能使结果表的外观和行为类似于“未搜索”表?
最佳答案
我想为答案 #1 做出贡献,这就是我所做的并且对我有用
在方法中
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
而不是从参数 tableView 中分配单元格
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
直接从 View 上的 TableView 分配它,所以你必须替换它
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
有了这个
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
关于objective-c - UISearchDisplayController 的搜索结果具有与搜索表不同的单元格布局和行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8333532/