gpt4 book ai didi

ios - Segue 不显示导航栏

转载 作者:可可西里 更新时间:2023-11-01 01:59:19 24 4
gpt4 key购买 nike

我有 2 个 ViewController 正在呈现一个新的 ViewController

第一个是在导航 Controller 中,因此它可以按预期使用 segue 推送。

然而,第二个来自没有导航栏的 ViewController。我正在以编程方式呈现此 View 。然而,当目的地出现时,有 2 个问题......

1) 没有导航栏。2) 显示的 View 从第一个 TableViewCell 下方开始。

func goToLocation() {
let locationTableVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "locationProfile") as! LocationTableViewController
locationTableVC.documentId = selectedDocumentId!
self.present(locationTableVC, animated: true, completion: nil)
}

LocationTableViewController.swift

// MARK: - View Will Appear
override public func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UIApplication.shared.statusBarStyle = .lightContent

// Make Nav Bar Translucent and Set title font/color
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = .clear
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20, weight: .semibold)]
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back-arrow-white")

}

enter image description here

Segue 显示从第一个 TableViewCell 下方开始并且没有导航栏。 Segue shows starting below the first TableViewCell and without a navigation bar.

我试图像第二个一样重新创建的第一个 segue 看起来像这样...... enter image description here

最佳答案

使用 UINavigationController 推送 UIViewController,如下所示:

func goToLocation() {
let locationTableVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "locationProfile") as! LocationTableViewController
locationTableVC.documentId = selectedDocumentId!
let navigationController = UINavigationController(rootViewController: locationTableVC)
self.present(navigationController, animated: true, completion: nil)
}

关于ios - Segue 不显示导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47874576/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com