I would like to show the user a splash screen (a picture) while my Cocoa-based application launches. How would this be possible?
First thanks a lot. because my app running for a while time , so I want to show a splash before app running . Now if I show a window inside with a image , after that how to run the app? How to make sure that the app running after the splash showing ? How to do to get the sequence ?
First Thank you very much. And I show the window in applicationWillFinishLaunching method use orderFront,then hide it in applicationDidFinishLaunching: use orderOut,Now I found that the mainWindow not to show and the app terminate ,why ? How to do to resolute this question? Thanks!
Although Peter's answer is ultimately correct (you should rewrite your app to launch faster), sometimes that's not a practical option. For example loading code later in the application may take too long (e.g. a data acquisition application), forcing it to be loaded at startup. If you decide that you want to show a splash screen, the easiest way is to show it in the application delegate's applicationWillFinishLaunching: method. Create a splash window in your applications MainMenu.nib and add an outlet to your app delegate referencing that window. You can then put the window onscreen in applicationWillFinishLaunching: and hide it in applicationDidFinishLaunching:. Note that the main thread's NSRunLoop is not iterating during this time, so if you want to update the splash screen (with status, a progress bar, or such), you'll need to manage those redraw events yourself.
Again, think very hard about whether the long startup is necessary. If it is, showing a splash screen with a progess indicator is the minimum that you owe your users.
Why do you hate your users?
Seriously, don't do this. Don't make your users wait to use your app. Make your app launch quickly instead.
(And just in case you insist on an answer: Show a window with the image in it, then hide the window when you feel the user has waited long enough.)
Just put up a window with the image and close it when you are done with your launch initialization.
Barry's answer above does not seem to work for document-based apps. Showing a splash window within applicationWillFinishLaunching: interferes with the startup sequence of the app such that the document window isn't created. I've uploaded an example project here. In applicationWillFinishLaunching:, comment out [_splashWindow orderFront:self ] and the document window will come up.
Related
I want to whip something up that would run a small script every time i clicked on the Desktop. Any hints on how to make this happen?
For those interested, the script would toggle the display of desktop icons.
I assume you mean on the desktop background, not any icon. You could create a transparent overlay window, use [window setIgnoresMouseEvents:NO] to make it receive clicks, and set its window level to something between the desktop and the icons (kCGDesktopWindowLevel and kCGDesktopIconWindowLevel).
You would presumably want to create one of those per screen and monitor for changes in the screen configuration to add, remove, or resize them as appropriate. Either observe the NSApplicationDidChangeScreenParametersNotification or implement the -applicationDidChangeScreenParameters: application delegate method (which amounts to the same thing).
I am making an app (software) for Windows. To run the app the user clicks on a .vbs file (or a shortcut to it). It takes a while to load up the main screen so I was wondering what's the easiest way to create a splash screen for my app? All it needs is to display an image on screen while it is waiting for the main window to appear. Once the main window appears, the splash screen can close.
Is there way a way to do that with a .vbs file? Happy to venture into Python or anything else but it needs to be simple to set up.
All I could find was related to Android which isn't relevant for me.
You can use a HTML-application (hta-file) to do this. Have a look at this description.
Is it possible to use a certain image for a loading screen when it's the first time the app is ever opened, and then after that use a different image for the loading for all visits after that?
Basically I'm creating about 10 files (not large in size) when the app is first launched and I wanted to display a message to the user so they don't think that the app normally takes more than a second to load up. I know I can display a popup on the home screen, but I have an animation that fires when you go to the home screen and also I need those files created before the user arrives there. Any ideas? Or maybe a different view point that I didn't mention?
You can't change the splash screen. Maybe you should rethink how your initial 10 files are created, and take Paul's suggestion of showing a popup control while you do the work, or better yet, offloading it into the background? I guess it depends if your created files are required for something in the UI
--edit--
Actually, the more I think about it, the more I favour a background thread doing the work while you have a popup control displayed to the user. It would allow you to give the user feedback on what is actually going on. If your popup says something like "Preparing this application for its first run...", and then shows a progress bar that updates when each file is created, the user is getting feedback on exactly why the app is taking so long to load the first time. Otherwise they may think "This app is very slow, I wonder if there is a better one out there"
I'm not sure if this is what you were thinking when you said "Popup", but you could create a full screen Popup (in the System.Windows.Controls.Primitive sense of Popup) that completely covers your main UI so that the user can't see it.
Your temporary loading UI would be defined as a UserControl described in XAML/C# in the same way as a normal PhoneApplicationPage.
When your files are ready and you close the popup you should send a message to the View (i.e. .xaml.cs) of your main page that will cause the animation to be replayed with all contents visible.
I want to write an app for Mac OS X. The app/utility would act according to preset schedule. I will have different time intervals at which I want this app to show a certain image in full screen regarding if there are other apps running at the time.
The real question is how to check this time interval in the background and bring this app in-front and enter full screen. I know how to go full screen, but I am stuck at bringing this app in-front of all other apps.
To schedule a method to be called after an interval, just use NSTimer and one of its +scheduledTimer... methods.
To force your application to be active, call [NSApp activateIgnoringOtherApps:YES].
If you want your window to appear above absolutely everything, including the screensaver, set its level to NSScreenSaverWindowLevel + 1.
The only solution that comes immediately to mind is use AppleScript, e.g. if you execute the following AppleScript from within your app:
tell application "MyBackgroundApp"
activate
end tell
There is an Apple Tech Note with sample code for sending AppleScript from a Cocoa app using NSAppleScript.
How to force Mac window to foreground?
How to prevent a window to deminiaturizing when a user click on the dock tile of the window?
In one part of my application , I am miniaturizing the window and then have to ensure that user cannot deminiaturize it for a specified time .The application has more than one window.
Please suggest how to do this in cocoa.
This is against Apple's Human Interface Guidelines (see section 'Minimizing and Expanding Windows') and as a result there is almost certainly no way to do this.
You cannot. That is something the OS is doing and you can't influence it. You need to adapt your design so it's no problem if the user unhides the window.