佚名通过本文主要向大家介绍了storyboard页面跳转到代码页面,UINavigationController在代码页面没有成功显示等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: storyboard页面跳转到代码页面,UINavigationController在代码页面没有成功显示
描述:
解决方案1:
描述:
问题
storyboard跳转到代码界面,
UINavigationController
在storyboard界面显示,代码界面不显示
代码
我是在AppDelegate
里增加UINavigationController
的
//AppDelegate.swift
let storyboard = UIStoryboard(name:"Main",bundle:nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "LoginViewController")
//let viewController = LoginViewController()
let nav = UINavigationController(rootViewController: viewController)
self.window?.rootViewController = viewController
self.window?.addSubview(nav.view)
self.window?.makeKeyAndVisible()
//统一导航条样式
let textAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 19.0), NSForegroundColorAttributeName: UIColor.white]
UINavigationBar.appearance().titleTextAttributes = textAttributes
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor.red
在storyboard界面通过该方式跳转
//LoginViewController.swift
let chatListView = SingleChatListViewController()
self.present(chatListView, animated: true, completion: nil)
结果
这个首页是正常的
这个就不对了
解决方案1:
虽然没用过swift,但是你api貌似用错了
//在storyboard界面通过该方式跳转
//LoginViewController.swift
let chatListView = SingleChatListViewController()
self.present(chatListView, animated: true, completion: nil)
self.navigationViewController 的是用push跳转的,你的present是另外一种跳转方式