I have 2 ViewController
s that are presenting a new ViewController
.
The first is in a navigation controller so it works as expected with a segue push.
The second however is from a ViewController
without a navigation bar. I'm programmatically presenting this view. However when the destination is presented there are 2 issues...
1) There is no navigation bar. 2) The view shown starts below the first 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")
}
Segue shows starting below the first TableViewCell and without a navigation bar.
The first segue which I'm trying to recreate like the second looks like this...