【发布时间】:2018-02-18 13:56:28
【问题描述】:
我的 viewController 上有 tableView,还有一个 textField。 TableView 显示名称列表。当我单击具有名称的单元格时,我想获得该名称,例如文本字段文本。 有人知道我该怎么做吗?
【问题讨论】:
-
粘贴代码。那我直接告诉你一个代码
-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return names.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) let names = names[indexPath.row] cell.textLabel!.text = imena return cell } }
-
我的 textField 文本有问题,tableview 看起来不错
-
检查答案现在把断点打印出来。现在打印特定行的名称
-
@MilicaKnezevic 不要在 cmets 中发布代码。请edit您的问题提供所有相关细节。
标签: ios swift uitableview uitextfield swift4