【问题标题】:applicationDidFinishLaunching not called, using storyboards and swift3未调用 applicationDidFinishLaunching,使用情节提要和 swift3
【发布时间】:2017-02-26 18:23:55
【问题描述】:

当我运行我的应用程序时,applicationDidFinishLaunching 没有被调用。

这是我AppDelegate类的代码:

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    let statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }


}

我正在为我的应用使用 Swift 3storyboards

applicationDidFinishLaunching - not triggering 的答案建议将AppDelegate.swift 连接到情节提要中的应用程序对象。我那里没有任何应用程序对象。

我的应用没有主菜单,它是 agent,因为我正在尝试构建类似于 Spotlight 的东西。

我应该怎么做才能让applicationDidFinishLaunching 运行?

【问题讨论】:

    标签: cocoa swift3 xcode-storyboard


    【解决方案1】:

    即使您的应用程序作为代理运行,您的故事板也应该具有以下结构:

    如果没有,则将一个蓝色立方体(对象)拖入应用场景,将对象的类设置为AppDelegate,然后从Application 按住control 拖动到App Delegate,然后选择delegate

    如果您甚至没有应用程序场景,请创建一个启用故事板的新项目,删除您当前的 Main.storyboard 文件并将新创建的项目的 Main.storyboard 拖到您当前的项目中。

    【讨论】:

    • 谢谢!我真的很怀念应用场景。
    • 如何在没有情节提要的情况下以编程方式制作它?
    • @fnc12 你必须在main 中设置代理,就在running 应用程序之前
    猜你喜欢
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 2023-03-25
    • 1970-01-01
    相关资源
    最近更新 更多