【发布时间】:2020-12-23 15:26:49
【问题描述】:
我有两个视图控制器“FirstViewController”和“SecondViewControler”,其中包含一个按钮,该按钮显示一个名为“BibliothequesViewController”的新视图控制器按钮被点击:
@IBAction func onLibrariesButtonClicked(_ sender: Any) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: BibliothequesViewController = storyboard.instantiateViewController(withIdentifier: "BibliothequesViewController") as! BibliothequesViewController
self.present(vc, animated: true, completion: nil)
}
目前,BibliothequesViewController 包含一个通过 Segue 重定向到 FirstViewController 的按钮:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("SegWay being performed")
// Every segway has a beginning point and ending point
// We're trying to access the ending point
// as type FullScreenMovieController
// Then we're setting the chosenMovie variable of FullScreenMovieController to 1
let vc = segue.destination as! FirstViewController
vc.receivedSelectedLibraryFromBibliothequesList = self.selectedLibrary
print("vc.receivedSelectedLibraryFromBibliothequesList :", vc.receivedSelectedLibraryFromBibliothequesList )
}
这是执行 Segue 的代码:
self.performSegue(withIdentifier: "BiblioToLoginSegue", sender: self)
我需要实现的是:
重定向到实际呈现 BibliothequesViewController 的视图(FirstViewController 或 SecondViewControler)。
上面的代码会自动重定向到 FirstViewController,无论它是否是呈现 BibliothequesViewController 的那个。
我看不出我应该采用哪种方法来实现这一点。 我应该使用推送而不是出现在 FirstViewController&SecondViewControler 中吗?
【问题讨论】:
-
我认为你需要一个unwind segue
标签: ios swift xcode uiviewcontroller tvos