简体   繁体   English

navigationController.pushViewController 似乎在 Xcode 11 中不起作用?

[英]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.

相关问题 NavigationController pushViewController不起作用 - NavigationController pushViewController doesn't work NavigationController.PushViewController也会移动导航栏 - NavigationController.PushViewController moves the navigation bar as well navigationController.pushViewController方法返回未定义 - navigationController.pushViewController the method returns undefined 如何在UITableViewSource下访问NavigationController.PushViewController? - How to access NavigationController.PushViewController under UITableViewSource? pushViewController似乎无法与Storyboard和QLPreviewController一起使用 - pushViewController doesn't seem to work with storyboard and QLPreviewController MonoTouch: UITableViewController,NavigationController 在 NavigationController.PushViewController 之后是 null - MonoTouch: UITableViewController,NavigationController is null after NavigationController.PushViewController Xcode 9 更新后 pushViewController 不起作用 - pushViewController doesn't work after an Xcode 9 update 如果在mainQueue / mainThread之外运行,NavigationController.pushViewController崩溃 - NavigationController.pushViewController crashes if run outside of mainQueue/mainThread pushviewcontroller不起作用? - pushviewcontroller doesn't work? 为什么不'self.navigationController?.pushViewController(mainPage,animated:true)'工作? - Why doesn’t 'self.navigationController?.pushViewController(mainPage, animated: true)' work?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM