[在遵循了有关以编程方式制作没有Pod的侧面菜单的教程之后,我遇到了有关导航的问题。我将登录视图设置为根视图控制器,登录后将在其中显示主视图。发生此过渡时,应出现在侧面菜单中的导航栏不会出现,因此我无法访问侧面菜单。我知道我的侧面菜单有效,因为当我将主视图设置为根控件时,显示的栏会允许我单击侧面菜单。
场景代理人:
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
let nav = UINavigationController()
let mainView = LogInController()
nav.viewControllers = [mainView]
window?.rootViewController = nav
window?.makeKeyAndVisible()
我在登录控制器中使用的转换:
let homeView = HomeMenu()
homeView.modalTransitionStyle = .flipHorizontal
homeView.modalPresentationStyle = .overCurrentContext
present(homeView, animated: true, completion: nil)
没关系,我只是以编程方式添加了一个导航栏,并从那里添加了访问我的侧边菜单。