applicationDidFinishLaunching

applicationDidFinishLaunching

本文介绍了使用情节提要和swift3,未调用applicationDidFinishLaunching的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行应用程序时未调用applicationDidFinishLaunching.

The applicationDidFinishLaunching is not being called when I run my app.

这是我的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 3 故事板.

I am using Swift 3 and storyboards for my app.

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

The answer to applicationDidFinishLaunching - not triggering suggests to connect AppDelegate.swift to application object in storyboard. I don't have any application object there.

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

My app does not have main menu, it is agent, as I am trying to build something similar to spotlight.

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

What should I do to get applicationDidFinishLaunching running?

推荐答案

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

Even if your app is running as an agent your storyboard is supposed to have this structure:

否则,将一个蓝色立方体(对象)拖到应用程序场景中,将对象的类设置为AppDelegate,然后将Application拖动到App Delegate,然后选择delegate.

If not, drag a blue cube (object) into the application scene, set the class of the object to AppDelegate and control-drag from Application to App Delegate and select delegate.

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

If you even have no Application Scene, create a new project with storyboard enabled, delete your current Main.storyboard file and drag the Main.storyboard of the new created project into your current project.

这篇关于使用情节提要和swift3,未调用applicationDidFinishLaunching的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-24 07:30