OS X Lion: NIB/XIB doesn't seem to get loaded if app is launched as a Startup Item - authentication

I have a problem which is driving me nuts.
Suppose you have an app with a window that is set to "Visible at Launch". When you launch the app, the window immediatly appears.
If you add this simple app to the login startup items list, when you log in, the app is automatically launched and you have the window just opened in front of you. This is what was happening in Snow Leopard.
If you repeat the same steps in Lion, as soon as you log-in, the app is launched but the window does not appear.. It seems that the NIB doesn't get loaded.
To make it appear you have to click on the app icon in the dock (even if the app is already launched).
This happens even if you specify [NSApp disableRelaunchOnLogin] according to Apple documentation here.
Things become worst if your app has NSUIElement = 0 and therefore it doesn't have neither an icon in the Dock, nor a Menubar. In this case there's no way to make the window to appear.
Is there a way to obtain the expected behavior of Snow Leopard? Am I missing something?

Related

How to prevent the app from automatically open a window when launched?

I am developing a OS X app and want it to run without dock icon but with a icon in the menubar. I have added the menubar utility and tried to set the following code in applicationDidFinishLaunching:
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
It works well, except that the app will still show the window when launched. How to prevent this? I can't set the LSUIElement in Info.plist because I want this behavior to be changeable in the runtime.
Thanks in advance!
Edit
It seems that the Visible At Launch is unchecked by default... I am using storyboard so I created a new project, choose Main.storyboard -> Window Controller Scene -> Window, and found it unchecked, but the window will still open automatically.
image (cannot post it directly with <10 reputation)

How can I bring an OSX app to the front?

I'm working on a small, OSX app (it's a menubar app). When I initially build/launch the app, it goes to the foreground and all other apps go to the background (as they should). When I click on another app, that app comes forward and my app goes back (as it should), but when I click back on my app, it doesn't come forward again. The other app stays as the front-most app (regardless of what that other app is).
The big problem with this, aside from it just being weird, is that none of the hover actions or cursors work on my app when it is not the frontmost app.
Is there a way to programmatically force it to the front? How come clicking on it doesn't bring it forward?...
I found the answer in this question. It can be done using either this:
[[NSApplication sharedApplication] activateIgnoringOtherApps : YES];
or this:
[[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];

Graphics error with NSStatusItem

My application uses NSStatusItem to be visible to the user.
So I set 'Application is agent (UIElement)' to YES, which basically hides the menu bar of the application, and hides the icon from the dock.
Now, I didn't delete the menu bar, so I can still react to shortcuts like cmd+W to close the preference window, or cmd+q to quit the application. The problem is, that anytime I use such a command, the menubar get's messed up.
I've noticed that other Apps which run in the background, like Growl 2, have the same issue.
I have no idea how to fix this.
Hopefully someone of you can help me
I'm running Mountain Lion.
thanks!
HINT
It probably has something to do with the 10.8 SKD. I have never noticed this issue before in any application.
How about move the whole Window menu to be Application menu submenu and then hide it?
You will still receive shortcuts and the highlited menu will be the application menu that is by anyway there (i suppose so, how else you will open preferences window? also shortcut?).

iOS Multitasking App Launch

I developed an app for IPhone and it's posted to itunes for approval. Now when I test the app I found out a strange behavior which I think should be rectified. When I launch app first time, the app launched and when I press home button it closes but when I tap the app icon to open it again it opens where it was last closed.
How can I change the view to first view of the app when it's launched after closing by Home screen button?
If you don't want your app to run in the background you need to set the "Application does not run in background" key in the info.plist file. This means that your app will completely restart every time your user returns to it. Take time to decide if this really is the best move for your app. Allowing users to return to where they left off or remembering information about the last session can be a big plus.
If you do not set the info.plist value like I mention above you can manage the way your app behaves by using the: applicationWillEnterForeground: in UIApplicationDelegate or you could observe UIApplicationWillEnterForegroundNotifications. Read up on all the available notifications and methods available for this in the UIApplication Delegate documentation.

iPad apps. Exit(0) stay on 'taskbar'

(ios 4.2)
When I force quit the application (exit(0);), the application quit, but the iPad "taskbar" doesn't seems to be refresh(app stay on it)
Do you have this behaviour? If no, how did you completely close?
(i know force quit are not "Apple friendly", but it's for a custom app)
Thanks!
Whatever the fate of your app's process is, its icon will always remain on the app switcher, as a "recently-used" app, until the user taps and holds, and removes it using the minus icon. I don't believe there's anything you can do to make iOS not display it there.
The process will already have quit, though, since you told it to exit(0).