objective-c - UISearchDisplayController 的搜索结果具有与搜索表不同的单元格布局和行为

标签 objective-c ios cocoa-touch uitableview uistoryboard

我正在使用 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/

相关文章:

objective-c - 我应该使用什么 UIApplication Delegate

iphone - 将 UITextField 与长字符串一起使用时出现问题

iphone - 在 NSThread 中使用 Singleton 同步数组

php - 允许通过自己的网络服务器 iOS 7 发送电子邮件?

ios - 使用 PFQuery 获取所有 PFUser

iOS 设置包 : How to validate input

iphone - NSNumber 和 float ?

ios - 方法是否可能(或建议)识别其调用方?

iphone - 什么时候应该在 cocoa 中使用摆姿势?

objective-c - UIwebview 中的 UIActivity 指示器