ios - 以编程方式将选项卡栏添加到 ViewController

标签 ios swift xcode uitabbarcontroller uistoryboard

我的 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?
    }
}

TabBarController.swift

UploadConfirmationViewController.swift

最佳答案

您需要做的是呈现选项卡栏 View Controller ,而不是嵌入其中的 View Controller

关于ios - 以编程方式将选项卡栏添加到 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44684149/

相关文章:

ios - WKWebView 确实在 swift iOS 中完成了页面加载?

iphone - 移动平台上的 Adob​​e AIR

iOS/ swift : directly manipulate remote MySQL over SSH

xcode - 使用 Cocoapods 导入 SwiftyJSON 时出错

ios - 将应用程序启动到导航 Controller 内的 ViewController

objective-c - Mac App Sandbox 组容器问题

ios - iOS VoIP 推送有效负载与静默通知的有效负载相似吗?

ios - 利用外部加载 Nib 中的 IBOutlets/IBActions

iphone - 如何在 iPhone 中保存带有标签的图像?

Swift XIB 设置标签文本