Change loading image? - iphone

I want to have my loading image be different each time i start the app. Is there a way to change this to something else once the app's started?

Not technically, no. The startup images are located inside the application bundle - as part of iOS's sandboxing, applications can't change or modify files inside that bundle (so your Info.plist and your background images).
It would be possible to have your startup image be black, and then swap it out for another splash screen that you hold for a few seconds as soon as your applicationDidFinishLoading method is called - but remember this will degrade the user experience, since you'll be delaying the time it takes to get into the app.

Related

Is there a way to always use the default.png when returning from background?

In one of my apps when returning from background I get a non consistent behavior:
Sometimes I get the default.png and sometimes I get a snapshot of the last screen which the app was in.
In both cases it takes the UI a good second or two to respond again.
Therefore I would rather show the default.png rather then "unresponsive UI"
Is there a way to make the app display the default.png always until the app becomes active again?
Currently the "stupid" way to do it I thought about is by displaying some Modal view with the default.png and removing it on return to foreground.
Few Clarification:
I am doing this to avoid unresponsive UI.
I am using the default.png as it looks like loading and gives a better experience then unresponsive UI
The app has to run in background.
(And to whoever asked - no it is not closed when I sometimes return and see the default.png and not the last UI state - App loading from the start has a very different path and I'm sure of that)
Thanks in advance.
This is not a correct behavior and you may experiencing a bug. Basically as long as your app is in the background, when you launch it, you should not see the default.png, unless you remove it from background (double click on home button and delete that app).
For future people interested in this you can use the fact the last view in the app is used to be displayed when the app loads back.
You can display a VC as your moving to background which will represent some loading - hence achieving the desired behavior.
I've already seen a few other apps using the same behavior in cases operations are ran when coming back into the app.
Most probably, you are taking too long (performing too many calculations) in methods such as applicationWillEnterForeground:, applicationDidBecomeActive:, etc. As a simple test, try commenting out the code in these methods and see if the problem occurs again.
Simply set in your Info.plist the property "Application doesn't run in background" to YES. The app will never go in background and when the home button is pressed it will be simply terminated. So you're back to the pre-iOS4 behavior.
Note that when you see now the default image at start-up it is simply because your app has been terminated while it was in background. This is normal especially for apps that take a lot of memory and then don't free it enough before going in the background (I think the threshold for the OS is about 18MB but I'm not sure)

iPhone App Startup Screen

yet another basic question ... I have an app that takes about 4-5 secs to load.
I want to use the time and show a startup screen that
is visible at least for 4 seconds, and
shows until the app is loaded and ready to show
How can I build that into my app?
Default.png is just the starting point. That will give you a splash screen (the Apple user interface guidelines suggest that the splash screen should look like the first screen to make the app look as if its loading faster - but that's actually a bad user experience IMHO).
The splash screen disappears as soon as the first view is shown. However, if your code is still doing stuff that renders the interface unusable, it can be worthwhile to make your first view look like the splash screen, possibly adding a progress bar, then swap that out for the first real view when your app is actually ready for user input.
Looks like a job for Default.png
http://iosdevelopertips.com/cocoa/defaultpng-the-secret-of-the-load-screen.html
Don't forget to be careful of your capitalization.
Have your application start with a view that shows the initialization progress and after the initialization is complete, replace it with your app's main view. Make sure to defer the initialization step with -performSelector:afterDelay or place the initialization code in -applicationDidFinishLaunching, so that the Default.png doesn't show up but for a very small amount of time and you can show your progress view.
Refer to this StackOverflow question. However, if your app takes 4-5 seconds to load, I would focus on improving its performance. Can you do some operations later, rather than at startup? Splash screens are generally a bad user experience and are discouraged in the Apple Human Interface Guidelines.

Good ways to dynamically generate the start image of an iPhone/iPad app

I'm self-learning iPhone development and I see that one of the aspects of an iPhone/iPad app is the start image that gets displayed when your app is run. I'd like my start image to display some basic info about the user when the app is launched, but that info has to first be collected by the user when the app is first run. That tells me that I either need to dynamically generate the start image after the user enters their information or I need to place a label of some sort on top of my static start image in order to accomplish this. The first time the app launched and before the user enters their info, the start image can be anything or nothing at all, I'm not concerned about this.
So, my questions are...
Can you place controls, like a label, on top of the start image when your app is launched?
If not, what's a good approach to dynamically generating the start image after the app is launched for the first time and the user info is collected?
If there's no way to change this start image (thanks kristopher!), can I instead display my dynamically generated image for a set amount of time (~3 seconds) as soon as the start image closes? Do I even have to use a start image at all?
Thanks so much in advance for your help! I'm going to begin researching this question right now.
To answer number 3, Yes, you need a start image. It should look like your dynamic start image but without the dynamic information.
To display the dynamic information briefly after launch, just use a modal view controller on top of whatever view controller comes up first (called viewController below):
SplashScreenController *splashScreen = [[SplashScreenController alloc] initWithNibName:#"SplashScreenController" bundle:nil];
[viewController presentModalViewController splashScreenController animated:NO];
[splashScreenController release];
[viewController performSelector:#selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:3];
Obviously you need to create a UIViewController subclass and xib file called SplashScreenController.
Apps can't change their start images. Those image files, as well as other files in the app's bundle, are treated as read-only by the OS.
If you don't have a startup image, then the user will just see a black screen for a second or two (or more, depending on how big your app is). It's a good idea to have a startup image.
You can display whatever you want after your app starts running.
I do something similar to what you are trying to accomplish, except I do not display user information. If you want to see what I did, check out my app How Long Can You Tap It (free). The Very first image, as Kristopher mentioned, is not changeable. It will be displayed for as long as the application takes to load. Then, the image will disappear and show your initial viewController, which will be whatever you want. In my app, it simply is the same image is the initial image, but instead of saying LOADING I display text telling you to Tap the screen to start playing. If you don't want to rely on the user to tap the screen to continue, you can do what Frank said and dismiss it within X number of seconds. If you want more code than what Frank provided, let us know.

iPhone Animated Loading Screen

Is there a way to have an animated loading screen for my iPhone application as opposed to the Default.png that I currently am using?
In short - no. The purpose of the Default.png is to give the iPhone OS something to display to the user while it loads your application in. The best you can do is to speed up the initial load of your application (say defer your resource loading until after the program is running), then add your own animation while you actually load your resources 'behind the scenes'.
If you think of it as an animated loading screen then no, but having the first view of you application load all the data and do something while it is doing that then surely yes, but I am trying to do that and am failing at the moment
As far as I know, unfortunately not. The point of the lightness of default.png is to allow the app to do intensive ramp-up behind the scenes. Animation would eat precious CPU cycles.
However, if you need to do more processing once your app has launched - you could do a threaded CAnimation during this time.
no, but if your initialization take lengthy time.
you can add an customized animating launching view once the application is launched.
for short.
after launched, before all the real initialization, alloc, init and display a view which is exactly the same as default.png but with animating effect.
while that animating view is displaying, init the real stuffs of your application in background
replace the animating view while done
You can do what one of the app which I know does. They have created series of images, which when displayed in sequence will make one believe that the splash screen is animating. You can check this app to get an idea: TravellerID
Hope this helps.

How i calculate loading time of a application in iPhone?

I want to add a loading bar at the initial of the game which is customized loading bar.
for that i need to calculate the loading percentage to show loading progress. Is there any way to calculate the loading time of the application? please help me.
If i add Default.png in my resources folder, it will seen at the time of application loading. How it works? I want to customize it.
You can change the Default.png to your liking and even exchange it between application starts, but it's still a static image that cannot be animated. It's displayed while the iPhone OS is bootstrapping your application. Once the application enters your own main function, you can display whatever you want - from this point on, what's loaded and what's displayed is under your control.
Regarding progress display, I can only speak from a game developers point of view. Normally, you know how many resources you're loading (textures, sound files,...) so you can load e.g. one resource per main-loop pass and display the progress accordingly.
I think your progress bar needs to be based on progress and not time. Remember that some hardware is faster than others. The 2G iPod touch is the fastest with (I think) the original iPhone the slowest.
Your Default.png image is entirely static. Sounds like you'd take a screenshot of your loading screen when it has zero progress and use that.