在View上执行segue,从另一个viewcontroller调用“segueing”函数

时间:2018-06-15 13:53:21

标签: ios swift xcode

我正在尝试从DynamicView到Home执行一个segue,从UITableView(NavigationManager)调用“segueing”函数。

从DynamicView上的按钮调用 presentToSelectedView()函数执行segue,但从NavigationManager调用相同的函数会执行该函数,但不会发生segue。

为什么会这样?

左侧是NavigationManager,右侧是DynamicView

screenshot

来自NavigationManager

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    switch indexPath.row {

    case 0:

        print("Going to: Home")

        let performer = DynamicView()

        performer.presentToSelectedView(viewName: "Home")

    default:
        performSegue(withIdentifier: "companias", sender: self)

    }
}

来自DynamicView

func presentToSelectedView(viewName: String){

    print("Received segue request to: \(viewName)")

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let VC = storyboard.instantiateViewController(withIdentifier: viewName)

    navigationController?.pushViewController(VC, animated: true)

}

@IBAction func test(_ sender: Any) {

    self.presentToSelectedView(viewName: "Home")

}

0 个答案:

没有答案