How to use Sleep in the application in iphone - iphone

I have used to loading a default image in my appication. So i have set to,
Sleep(3); in my delegate.m class.
But sometimes it will take more than 6 to 7 minutes. So i want to display the image 3 seconds only and then it goes to my appilcation based on my requirements.
Which one is best way to do that?
Sleep(3) or [NSThread sleepForTimeInterval:3.0] or something else;
And i must display the image 3 seconds only. Please explain me.
(Note: And I declared setter and getter methods only in my deleagte class.)
Please explain me.

As Rob noted, Apple strongly recommends against a splash screen unless it hides some necessary behind the scenes process (like loading game graphics.) It is so strongly discouraged that some people have claimed that their apps have been rejected for using an unnecessary splash screen.
The default.png doesn't exist to create a splash screen. Instead it exist to allow you to create the illusion that your initial view loads faster than it does. You supposed to use it to provide an image of your initial view so that the enduser can begin to cognitively orient themselves to the interface. By the time they have oriented themselves to the interface and moved their finger to touch the interface, it is live.
Why? Because iPhone apps are supposed be quick in, quick out. People don't sit down to use them at a desk like a desktop. People use then on the go. Sometimes they use them in the middle of a conversation.
I tell my clients to test out the usability of their apps (except for games) while walking, riding an exercise bike etc as well as in the middle of a face-to-face and phone conversation. In those circumstances, a three second pause is a big deal and very noticeable especially if the app is a practical app. Imagine if every time you opened the Contact app you had to pause three seconds to see an Apple splash screen. You would get peeved in a hurry.
The key thing here is that an unnecessary splash screen doesn't add any value for the user. It is a selfish act on the part of the software publisher to eat the end users time so that the publisher can build brand recognition for the sole benefit of the publisher. Wasting three seconds of the users time every time they use the app adds up in a hurry. (In my experience, it also makes the user perceive that the overall app is slow and clunky.)
However, if you do want to shoot yourself in the foot or if you have a client hell bent on a splash screen, you do it like this:
The splash screen appears until the first view loads so you delay the loading of the first view. In the app delegates applicationDidFinishLaunching: method, remove all the code that loads the first view into the window. Replace it with a NSTimer. Put the code to load the first view in the timer's fire method.
With that setup the app will display the default.png as it launches, when it gets to applicationDidFinishLaunching:it will appear to pause from the end users perspective because no view will appear to replace the default.png.
You should note that the standard launch time for an app is 3-5 seconds. So you may not have to do anything to show the splash screen for 3 seconds. It might happen automatically.

Apple strictly recommends against this (using sleep in this way), especially in the scenario of showing a splash screen.
The best thing to do is create a view that looks like your Default.png file, then have that be the first NIB.. you could then set an NSTimer to transition (with animation if you want) to your main view/window/controller.

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)

Is it a good idea to use an video as splash screen in my iphone app?

I'm about to finish an app and now I wanted to add an animated splash screen with my company logo after the app finishes loading and launching. I can just use an animation with openGL for this, but I was wondering if it would be better to use a video..it's easier for me and the artist because he will only provide with an small video which i would reproduce after my app finish launching..less work.
I wonder if it's a good idea to do so...can I reproduce a small short video with the logo of my company or should i stick to making an animation ?
Also, reproducing video is memory intensive ?, because I'm loading some texture after my app finishes launching, and im wrried about that.
If i end up reproducing an small video, can i make it non interactive ? ( no pause, play stop, ect) so it looks like just as another animation to the eyes of the user ?
My other preocupation is quality...the quality of the video will look dramatically different to my animations in openGL ?
Thanks !
I can't tell you about the technical stuff, but what I can tell you is: don't use a splash screen. Directly from the Human Interface Guidelines:
Supply a launch image to improve user experience; avoid using it as an opportunity to provide:
• An “application entry experience,” such as a splash screen
...
Because users are likely to switch among applications frequently, you should make every effort to cut launch time to a minimum, and you should design a launch image that downplays the experience rather than drawing attention to it.
The HIG guidelines are intended (as far as I can tell) for Apps on the iPhone.
This is different from Games on the iPhone.
If your app provides some utility to the user, I agree completely with #Costique, #fabian789, and the HIG. The app should start instantly, with minimal loading and other distracting crap.
For a game, however, intros and the like are not only expected, but can also lead to a better user experience. My recommendation is to use a UIView Animation for only a small portion of the screen (the logo only). See Angry Birds as an example - their "animation" starts the same time the user's options do, so your animation (while quite pretty) doesn't block the user from using your app.
Disclaimer: the following is an entirely subjective humble user opinion. Please, don't take it to heart.
I hate video splash screens on my iPhone/iPad, however beautiful and stylish. What I like is apps which launch instantaneously. On iOS 4 chances are, I will see the startup animation once a month when the OS decides to terminate your app when the device is low on memory. So, now I tap the app icon and see the animation, now I tap it and don't (because it's already launched). It's inconsistent, out of your (and my) control, and ultimately makes little sense.
From both quality and aesthetics points of view, I think GL animation would better fit (hopefully) intense addictive action which follows. I'm not sure, however, that you will be able to load any resources in the background, while the animation plays, without making the animation stutter.

iphone MultiTasking?

Hello I'm trying to get the multitasking work properly, but unfortunately I'm kinda lost. My problem is when I re-enter the game, it takes several seconds for the game to come back and show the pause screen. My question is; is there any way to put some sort of loading screen until the game comes back, so I can at least indicate that its not frozen? I've never used Xcode directly. I'm using Unity 3d to build my game. I made a little bit of research and if I'm not mistaken I'm supposed to use "applicationDidEnterBackground" app delegate method. My question is How can I put a custom loading screen using that method in Xcode?
Thanks
In -applicationDidEnterBackground:, you're given the opportunity to "clean up" the UI before the screenshot is taken. Apple says you should remove "sensitive data" (the screenshots might be persisted to "disk"?), but it also lets you do other things. In one app, we hide the label on a countdown timer so it doesn't appear to jump when you switch back to the app.
To change the "loading screen", simply display a full-screen view over the other views and remove it in -applicationWillEnterForeground:. Alternatively, pause the game in the first place!
(Really, you should be pausing the game in -applicationWillResignActive: which happens when the user double-taps home or the user receives a SMS/notification. I'm pretty sure it's called when the app is backgrounded, too.)

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.

Can we use sleep(9);Function

Can we use sleep function at applicationDidFinishLaunching to take more time to show Splash screen?.Is this Valid in HIG
You can use the sleep function in applicationDidFinishLaunching, but doing what you want to do is frowned on in the HIG
Avoid displaying an About window, a splash screen, or providing any other type of startup experience that prevents people from using your application immediately.
Yes. But it's really stupid. Also if you don't exit applicationDidFinishLaunching in a certain amount of time (say, 2-10 seconds) your app will be killed by the system.
I never really understand the view against a splash screen as most apps I run on iPhone and iPad have them. I see not issue with a company logo on display for 2 - 3 seconds rather than a Default.png that flashes on screen for a nano second leaving the user to wonder "er what was that?"
Nearly all applications have a splash screen either on mobile devices or desktop. I agree with not delaying the user experience but I also agree with a company logo.
If a user is put off by a 2-3 second delay then they really should go on a "learn to chill" course!