【发布时间】:2016-11-22 07:37:52
【问题描述】:
我正在使用 Swift 2 开发应用程序。在我的应用程序中,我将 JSON 数据解析为表格视图。当我点击一个单元格时,它成功移动到另一个视图控制器,但我无法获取 json 数据。
这是我的视图控制器中的代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath){
var cell = self.TableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath: indexPath) as! CustomTableCell
let strbookdetail : NSString=arrDict[indexPath.row] .valueForKey("booking_detail") as! NSString
let strdrop : NSString=arrDict[indexPath.row] .valueForKey("drop_address") as! NSString
cell.Bookdetail.text=strbookdetail as String
cell.Dropaddress.text=strdrop as String
return cell as CustomTableCell
}
//It helps to parse JSON data to table view.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
TableView.deselectRowAtIndexPath(indexPath, animated: true)
let tripcontroller = self.storyboard?.instantiateViewControllerWithIdentifier("UpcomingController") as! Secondcontroller
navigationController?.pushViewController(tripcontroller, animated: true)
}
当点击单元格时,它有助于移动到其他视图控制器SecondController
在我的SecondController 中有两个UILabels。在这些标签中,我想显示数据,即 strbookdetail 和 strdrop
如何在两个视图控制器之间传递引用?
【问题讨论】:
-
文档中的 This topic 可能会对您有所帮助
-
你是不是推送VC成功了,但是你没有写传数据的代码
-
我已经通过情节提要提供连接一切正常,但在我的表格视图中有单元格..每个单元格都有不同的数据,所以如果我点击特定单元格,它应该根据它们的单元格获取数据
-
是的@Anbu.Karthik....我没有编写代码来传递数据
标签: ios swift uitableview swift2 uistoryboardsegue