我用这种方式填充 UITableViewCell 的 json 数据
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("jsonCell") as! Celda
var dict = arrRes[indexPath.row]
cell.nombre1.text = dict["nombre"] as? String
cell.nombre2.text = dict["calle"] as? String
cell.id.text = dict["id"] as? String
return cell
但是我无法传递我的数据,如果我想传递id
文本,我的prepareforsegue代码是什么?
最佳答案
您应该进行一些尝试,然后发布您的尝试。但这是一个例子......
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "Identifier" {
let navigationContoller = segue.destinationViewController as! UINavigationController
let controller = navigationContoller.topViewController as! MyViewControllerToSegueTo
let indexPath = self.tableView.indexPathForSelectedRow
let dataToPass = data[indexPath!.row]
controller.recieveingVariable = dataToPass
}
}
关于ios - 使用 json 填充的单元格准备segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35095980/