[英]navigationController.pushViewController doesn't seem to work in Xcode 11?
I have created a basic single view application.我创建了一个基本的单视图应用程序。 Using Xcode 11 now.
现在使用 Xcode 11。 I always build apps programatically because the tutorials I have started with never use the interface builder.
我总是以编程方式构建应用程序,因为我开始使用的教程从不使用界面构建器。 For some reason not able to get the pushViewController to work.
由于某种原因无法让 pushViewController 工作。 Seems to work just fine in my other projects built using Xcode 10.
在我使用 Xcode 10 构建的其他项目中似乎工作得很好。
In App Delegate在应用程序委托中
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow()
window?.makeKeyAndVisible()
let nc = UINavigationController(rootViewController: ViewController())
window?.rootViewController = nc
return true
}
In my viewController在我的视图控制器中
@objc func handleChat(){
print("Chat pressed")
navigationController?.pushViewController(InboxViewController(), animated: true)
}
AppDelegate.swift AppDelegate.swift
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let VC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewController") as? ViewController
var Nav: UINavigationController? = nil
if let VC = VC {
Nav = UINavigationController(rootViewController: VC)
}
window?.rootViewController = Nav
return true
}
Remove SceneDelegate.swift删除 SceneDelegate.swift
Goto Info.plist转到信息.plist
Remove Application Scene Manifest删除应用场景清单
It's work for me.这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.