【发布时间】:2015-12-23 17:25:22
【问题描述】:
我已经用它创建了一个表格和一个搜索栏控制器。我使用了一个结构来创建表格内容。我只想将所选单元格中的数据存储在变量中。我是一个新的 iOS 开发者。请帮助 :) TIA
//my struct
import Foundation
struct areas
{
let name : String
}
// table contents
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
var place :areas
if tableView == self.searchDisplayController!.searchResultsTableView{
place = filteredareas[indexPath.row]
}
else{
place = places[indexPath.row]
}
cell.textLabel!.text = place.name
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
return cell
}
如何使用 didSelectRowAtIndexPath 知道被点击单元格的内容?
【问题讨论】:
标签: ios swift uitableview uisearchdisplaycontroller didselectrowatindexpath