我假設你想要實現的是將數據從一個標籤傳遞到另一個標籤。
「現在,我怎樣才能返回到第一標籤頁用賽格瑞?因爲我需要傳遞,以做一個查詢到數據庫的參數。」
其實,你不「T必須執行SEGUE來傳遞數據,而不是你能做到以下幾點:
// somewhere in your code when you need to pass data to another tab viewController:
if let tabBarController = tabBarController {
let secondTabViewController = tabBarController.viewControllers![1] as! SecondViewController
// let's assume that you want to pass a string
secondTabViewController.str = "my str!!"
}
SecondViewController:
class SecondViewController: UIViewController {
// here is the string that had been passed from the first tab viewController:
var str:String?
override func viewDidLoad() {
super.viewDidLoad()
// note that the output is: "Optional("my str!!")"
print(str)
// do optional binding:
if let unwrappedStr = str {
// output is: "my str!!"
print(unwrappedStr)
}
}
}
我希望它有幫助。
你需要使用一個unwind segue回去 – Paulw11