Configuring Starting Location
Maps UIKit SwiftUI
In this lesson, I want to go over an interesting exercise of setting up our navigation bar with our LBTATools stacking methods. Once we have the starting location configured, we'll push a dummy view controller onto the navigational stack.

Comments (3)
Dustin Doosun Yang
3 years ago
I do still see navigationContoller is nil. AnyIdea? @objc fileprivate func handleChangeStartLocation() { let vc = UIViewController() vc.view.backgroundColor = .yellow let button = UIButton(title: "BACK", titleColor: .black, font: .boldSystemFont(ofSize: 14), backgroundColor: .clear, target: self, action: #selector(handleBack)) vc.view.addSubview(button) button.fillSuperview() print(navigationController) navigationController?.pushViewController(vc, animated: true) } truct DirectionsPreview: PreviewProvider { static var previews: some View { ContainerView().edgesIgnoringSafeArea(.all) // .environment(\.colorScheme, .light) } struct ContainerView: UIViewControllerRepresentable { func makeUIViewController(context: UIViewControllerRepresentableContext<DirectionsPreview.ContainerView>) -> UIViewController { return UINavigationController(rootViewController: DirectionsController()) } func updateUIViewController(_ uiViewController: DirectionsPreview.ContainerView.UIViewControllerType, context: UIViewControllerRepresentableContext<DirectionsPreview.ContainerView>) { } } }
Dustin Doosun Yang
3 years ago
I see the same issue even if I tried downloaded project
Dustin Doosun Yang
3 years ago
I solve this by having window.rootViewController = UINavigationController(rootViewController: DirectionsController())
Brian Voong
3 years ago
NSD_bigjas00
3 years ago
I used the following: @objc func handleStartLocationChange(){ let vc = UIViewController() vc.view.backgroundColor = .blue present(vc, animated: true, completion: nil) } This way the view can be dismissed by swiping down.
shivaskanthan
3 years ago
Hi Brian, just to confirm, using fillSuperviewSafeAreaLayoutGuide() is the same as doing this right? containerView.anchor(top: view.safeAreaLayoutGuide.topAnchor, leading: navBar.leadingAnchor, bottom: navBar.bottomAnchor, trailing: navBar.trailingAnchor)
Brian Voong
3 years ago
HELP & SUPPORT