【发布时间】:2015-07-30 13:25:05
【问题描述】:
我有以下问题。 我在一个用 swift 编写的 tableView 中设置了一个搜索栏。每个 tableView 单元格都有一个标签和一个图像。问题是当我尝试搜索 searchDisplayController 时显示正确的标签但错误的图像(它显示数组中的第一个图像)。
应用加载时:
当我尝试搜索时:
如您所见,图像从头开始,并且图像视图没有为 iPhone 单元显示正确的图像。
提前感谢您的回答。
EDIT1:cellForRowAtIndexPath 代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! CustomCell
var friend : FriendItem
if (tableView == self.searchDisplayController?.searchResultsTableView)
{
friend = self.filteredFriends[indexPath.row]
}
else
{
friend = self.friendsArray[indexPath.row]
}
cell.label1.text = friend.name
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
let item = friendsArray[indexPath.row]
cell.setCell(item.name, image1: item.image)
return cell
}
【问题讨论】:
-
能否请您发布您的
cellForRowAtindexPath:方法? -
pbush25,我提供了代码,谢谢您的快速响应
标签: ios swift uitableview xcode6 uisearchdisplaycontroller