Skip to main content
 首页 » 操作系统

ios之转到当前 View Controller 的新实例

2024年01月01日66findumars

我在导航 Controller 中嵌入了 Storyboard View ,它显示数据库中的记录以及查看相关记录的链接。相关记录需要使用相同的 View 来显示其数据,同时仍然维护导航堆栈,以便用户可以返回到上一条记录。请记住,一些数据需要传递给新的 viewController,并且 UI 由一个 tableView 组成,每个元素都排成一行,如何实现这个 segue?

下面是 View 。如果可能,请使用 Swift 中的任何示例代码进行回复。

请您参考如下方法:

With some inspiration from this answer和@Jassi 的指导,这是最终产品:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
    let vc = storyboard?.instantiateViewControllerWithIdentifier("inventoryItemDetail") as InventoryDetail 
    vc.fmRecordId = item["inContainerRecordId"]! //this is the data which will be passed to the new vc 
    self.navigationController?.pushViewController(vc, animated: true) 
}