我的 Main.storyboard
文件中有一个 TabBarController
。
在我的 Upload.storyboard
中,我从 Main.storyboard
文件中呈现一个 ViewController,但是,它不包含选项卡栏。
viewProfile
按钮应该转到名为 Sharks
的选项卡,并在其中显示一个基于 Upload.storyboard
中收集的数据的 View Controller 。 (模态视图)。
我可以通过编程方式添加标签栏吗?还是我没有正确呈现正确的 VC?
// MARK: - Actions
@IBAction func viewProfileButtonPressed(_ sender: UIButton) {
let stb = UIStoryboard(name: "Main", bundle: nil)
let sharkProfile = stb.instantiateViewController(withIdentifier: "sharkProfile") as! SharkProfileTableViewController
self.present(sharkProfile, animated: true) {
// add tab bar here?
}
}
最佳答案
您需要做的是呈现选项卡栏 View Controller ,而不是嵌入其中的 View Controller
关于ios - 以编程方式将选项卡栏添加到 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44684149/