我创建了新的ios项目,我所做的就是去了main.storybord并将它嵌入导航控制器中。我得到了黑屏,我无法将任何东西拖到视图控制器中。
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:2)
无论你做了什么,我都得到了它,你必须遵循他的答案中所说的@iYoung,但是你的情况是拖放Navigationcontroller
并给它segue
到UIviewController
。所以在这种情况下Navigationcontroller
没有获得根视图控制器并显示黑屏。
UI输出:
在AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
self.window?.rootViewController = storyboard.instantiateViewController(withIdentifier: "ViewController")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
return true
}
答案 1 :(得分:1)