Rumah > Soal Jawab > teks badan
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)
这个首页是正常的
这个就不对了
PHPz2017-04-18 09:56:54
Gantikan
self.present(chatListView, animated: true, completion: nil)
dengan self.navigationController?.pushViewController(chatListView , animated: true)
dan ia akan menjadi ok
Anda menggunakan present untuk memaparkannya Jika ia tidak berkaitan secara logik dengan halaman yang dipaparkan oleh nav, anda boleh gunakan kaedah ini
怪我咯2017-04-18 09:56:54
Walaupun saya tidak pernah menggunakan Swift, nampaknya anda menggunakan API yang salah
//在storyboard界面通过该方式跳转
//LoginViewController.swift
let chatListView = SingleChatListViewController()
self.present(chatListView, animated: true, completion: nil)
Self.navigationViewController menggunakan tolak untuk melompat, hadiah anda ialah kaedah lompatan yang lain