English 中文(简体)
启动 Mac 应用程序时在 Windows 之间作出决定
原标题:Decide between Windows on starting the mac app

I have a Login.xib and a Main.xib and if you logged in once I store the token into a file. If this file with the token exists , I want to show the Main window instead of Login, because I already know which user it is.

以及我如何决定我应该展示哪个窗口?

最佳回答

我将检查您的应用程序代表 application did FinishLaunching: 方法中是否存在此文件。

如果文件存在, 则显示主窗口, 否则则显示登录窗口 。

< 强力 > 编辑 < /强 >

针对您的评论, 您需要查看 < a href=" https:// developmenter. apple. com/ library/mac/ #documentation/ Cocoa/ Reference/ ApplicationKit/ Classes/ nswindowcontroller_ Class/ Reference/ Reference. html" rel=“ nofollow” > NSWindowcurrent class。 基本上您想要控制的每一个窗口都将有一个 < em> NSWindowcurrent < / em > 对象 。

您还需要在应用程序中修改一些内容,以改变装入主窗口的默认行为,该行为将因您是否正在创建基于文档的应用程序而有所不同。

如果您的应用程序不是基于文档, 您的应用程序可以装入主. xib, 因为此程序设置在您的应用程序中的 info. plist 文件 。 基本上, 您的应用程序开始时, 它会查看信息. plist 文件, 以找出需要装入和装入哪个 nib 。 通常主 nib 包含一个菜单和一个窗口 。 只需删除窗口, 然后在单独的 nib 中重新创建它, 以阻止默认的窗口装入 。

If your application is document based then things are a little different. You will have an NSDocument subclass which should have a method called windowNibName which returns the name of the nib file to be loaded. Remove this method and instead override makeWindowControllers to return your NSWindowController objects. There is a bit more to it than this but this should get you started and the rest is beyond the scope of your original question.

问题回答

暂无回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签