Login.xib然后启动mainmenu.xib XCode OS X [英] Login.xib then launch mainmenu.xib XCode OS X

查看:153
本文介绍了Login.xib然后启动mainmenu.xib XCode OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何逐步显示用户的login.xib,然后根据结果显示mainmenu.xib?

What is the step by step guide to show a login.xib for the user then based on the result show the mainmenu.xib?

我尝试更改login.xib并将其常规"项目设置中的主界面"更改为它,但是在加载时我得到了:

I tried to change the login.xib and change the "Main Interface" in "General" project settings to it but when it loads I get:

Could not connect the action loginButton: to target of class NSApplication

我做错了什么?

推荐答案

您的login.xib的文件所有者是什么类?这就是错误消息的原因.您需要一个自定义控制器类来加载并拥有该Nib.对于MainMenu.xib,如果您有单个协调程序应用程序,则为应用程序委托.我建议保持该设置. Login.xib需要一个NSWindowController子类来拥有和加载它.您可以在applicationDidFinishLaunching中创建该控制器.控制器将加载笔尖并显示窗口.

File's Owner for your login.xib is what class? That's the cause of the error message. You need a custom controller class that loads and owns that Nib. For MainMenu.xib, that's the application delegate if you have a single-coordinator app. I'd recommend keeping that setup. Login.xib needs a NSWindowController subclass to own and load it. You'd create that controller in applicationDidFinishLaunching. The controller will load the Nib and display the window.

但还有其他评论:

在单协调程序应用程序中,XCode设置了一个拥有MainMenu.xib窗口的自定义应用程序委托类-MainMenu.xib Nib加载到NSApplicationMain中,因为它在Info.plist中列为NSMainNibFile

In a single-coordinator application, XCode sets up a custom app delegate class that owns the MainMenu.xib window -- the MainMenu.xib Nib is loaded in NSApplicationMain because its listed in the Info.plist as NSMainNibFile

因此,您可以尝试像上面讨论的那样将login.xib设置为NSMainNibFile,而该类将由您的应用程序代表拥有.

So, you could try making login.xib your NSMainNibFile like you've discussed, and that would be owned by your application delegate.

然后,您可以在用户登录时使用自定义窗口控制器加载MainMenu.xib.如果用户注销,则可以重新显示登录屏幕.当登录屏幕可见时,主菜单将不可见,因为它不是login.xib的一部分,并且尚未加载.

You could then load MainMenu.xib with a custom window controller when the user logs in. If the user logs out, you can redisplay the login screen. The main menu won't be visible when the login screen is visible because it's not part of the login.xib and hasn't been loaded.

我要严格建议的是将mainmenu.xib保留为NSMainNibFile,并为login.xib和登录后显示的用户界面使用自定义窗口控制器.

What I'd stringly recommend, though, is keeping mainmenu.xib as the NSMainNibFile, and having custom window controllers for login.xib AND your user interface that's presented after a login.

这篇关于Login.xib然后启动mainmenu.xib XCode OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆