How to let the app load with Default.png only when it is launched from scratch? - iphone

Example: My Default.png image shows the start screen of my app with an empty interface. When the app is launched from scratch the first time, this is cool. It appears like it started quickly. But when the user quits it and the app just goes to background, and then the user opens it, this sucks. Then I always end up with a wrong "snapshot" as launch image and my app then looks completely different after launch because it is like it was left the last time.
I would have to disable the Default.png when my app just goes to background, or I would have to enable it when it gets really terminated. Any way to do this?

It sounds to me like your app isn't being suspended. Every app that I've used that supports fast-app switching hasn't shown its default png when I open it after suspending it.
Are you sure your app is supporting fast-app switching and that it is being suspended?
Just updating my answer for some clarity that was revealed in the comments:
In order to take advantage of fast-app switching, the following conditions need to be met:
App needs to be compiled against the 4.0 SDK
App needs to be running on a multitasking-capable device such as:
iPhone 4
iPhone 3GS
iPod touch 3rd Generation
info.plist must not contain the UIApplicationExitsOnSuspend key.

Related

iphone:Multitasking in iphone not possible

Does iphone support multitasking for third party applications.Canone explain me how.
Assuming your device is newer than an iPhone 3G (or 1st gen iPod Touch), then yes, your application may run in the background. Note that even iOS4 doesn't allow multitasking on the older devices. What happens in iOS4 and above is that when you press the home button from an application, it switches the current app to the background - however, it is still running.
When working with games this means you have to use your application delegate to pause your game when the application is sent to the background, and (optionally) resume it when it returns, or present a "pause menu". It should also switch to a low/idle rendering loop (4FPS or similar), however, extra care has to be taken with iPad apps, which do not allow OpenGL rendering in an application that is currently in the background (in my experience). For these cases you have to completely disable the OpenGL render loop. These steps will prevent your application using unnecessary processing power while in the background.
You can see what's currently running in the background by double-tapping the home button on your device. The icons for all the apps will appear in a sliding list at the bottom of the screen. You can press and hold them to bring up the little X's allowing you to terminate the processes.

iPhone app update while still in background

I was wondering what happens if a user updates an app (through the app store/update) while the app is still in the background on iOS 4.x
I am planning a big update for my next release and I wanted to know if it is a special case I have to handle to avoid a crash.
Or can I trust the OS to restart the application on the next launch (or to kill the background process during the update), detecting that the application has changed instead of just doing a "applicationWillEnterForeground"?
iOS / Apple take care of that use-case for you, you don't need to worry about it. Your app will get terminated, so when the user next taps its icon you will have a relaunch.
Any app in suspended in the iOS "background" can get terminated by the OS at any time. The OS knows to do the "right thing" when the app's icon is tapped on again next. An app update would just be another case of that same thing happening.

iPhone - fast-app switching and iOS 4

I'm trying to get the following functionality in my iPhone app:
When backgrounded, stays running (doesn't have to do any background work)
When resumed, app picks up where it was left off
I'm mainly wanting the same screen on my app still up, as there are several UINavigationControllers within a UITabBarController.
I have done all of the following:
Made sure I'm compiling with 4.1 SDK
Set UIApplicationExitsOnSuspend to false
Handle DidEnterBackground and WillEnterForeground in my AppDelegate
Call BeginBackgroundTask in DidEnterBackground, to attempt to keep my app open
I'm using MonoTouch, but that it probably beside the point. I can take answers in Obj-C, for sure.
I've tested my app on a jailbroken phone with Backgrounder, and I see the "app in background" badge disappear immediately after pushing the home button. I also tried setting UIBackgroundModes in my Info.plist, but to no avail.
Is there anything I'm missing?
Or is this something I would have to implement on my own to resume the previous state of my app? Everywhere I've read talks like it should just work automatically.
If you don't want to be doing work in background, don't call beginBackgroundTask. That call is for situations where you want to do some kind of work in the background. And if you don't finish that work fast enough, iOS will terminate your app.
When I upgraded to iOS 4.x, my MT application started exhibiting this behavior without me having to do anything. iOS should take care of it for you.
I finally got in touch with someone on MonoTouch's irc.
In MonoDevelop there is an option to make a dual iPad/iPhone project, which I used. This is causing my app to behave as if it's running with the 3.2 SDK when deployed to the device.
I think my solution is to install the iOS 4.2 SDK that just came out, since this ads the new multi-tasking feature on iPad.
Not only do you need to support going into the background, you also need to support cases where your app has been terminated. In your app’s initialization code, you should resume the state that it was in. For instance, when you push a view controller, use NSUserDefaults to store a value for the currently-displayed screen, and then when you start read that value and display the associated screen.

GUI is stuck with uibackgroundmodes= voip, audio

I have tabbar-based application. When I put in my plist UIBackgroundModes (my application is supposed to support voip), the GUI doesn't load. It sucks on Splash screen and doesn't load the first tab view. When i remove the UIBackgroundModes property from info.plist, it works fine. More than that, pressing the home button when it stuck does nothing. Did somebody encountered a similar problem? (The problem exists on simulator)
Thanks,
Nava
It appears, that the problem happens on Simulator only, it works on the device... So the solution (temporary one) is not to put UIBackgroundModes into info.plist for simulator version.
You are responsible for loading/unloading the interface when going in and out of the background mode. You'll also need to update the interface accordingly when coming out of background.
iOS helps a bit by taking a screenshot before putting the app in background and displaying it when getting the app to foreground (a bit like Default.png when starting the app) and also some UIImage caching.
It might be worth sharing some code.
Supporting Background State Transitions
Supporting the background state transition is part of the fundamental architecture for applications in iOS 4 and later. Although technically the only thing you have to do to support this capability is link against iOS 4 and later, properly supporting it requires some additional work. Specifically, your application delegate should implement the following methods and implement appropriate behaviors in each of them:
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillEnterForeground:
applicationWillTerminate:
Being a Responsible, Multitasking-Aware Application
Applications that run in the background are more limited in what they can do than a foreground application. And even if your application does not run in the background, there are are certain guidelines you should follow when implementing your application.
Do not make any OpenGL ES calls from your code. You must not create an EAGLContext object or issue any OpenGL ES drawing commands of any kind. Using these calls will cause your application to be terminated immediately.
[...]
iOS Application Programming Guide
I see this bug as well. It's very annoying. It's as if the app is stuck in the simulator and won't keep going. When this happens, I know how to "unstick" it.
In the simulator I just go to menu Hardware > Lock and then unlock the phone again. Now I stop the debugger and start the app again. This seems to kick it back to life.
Fortunately this bug doesn't happen on a real phone, only in the simulator.

Developing iPhone app to Run on iPad - Auto Set 2x

Is there a way to programmatically set the iPad to run the iPhone app at 2x as it is launched (yet keep the iPhone app native). I understand I can create NIB files for each hardware platform, but for ease, I just would rather the app launch as if the user had tapped the 2x on the iPad. Thanks...R.J.
No. The pixel-doubling malarkey is not under your app's control, and is pretty much a crutch for apps that weren't designed for the iPad. If you didn't go nuts with specific pixel measurements in the original code, it shouldn't be difficult to move to the larger screen.
It's not quite program control, but you can get an app to start up in 2x mode on iOS 4.2.
I've had a couple of apps that have always started up in 2x mode, and very nice it was too, but I only worked out why this was today!
Steps:
Run iPhone app (e.g., from Xcode)
Use '1x' and '2x' buttons to select desired zoom level
Press home button to get back to launcher
Double tap home button to bring up task manager
Kill your app (hold finger down until icons start to dance, then press the '-' button on your app's icon)
(If you ran under the debugger in step 1, Xcode will tell you the program got a SIGKILL, and might stop somewhere random in the call stack; you can ignore this.)
Now next time you run the program, it will start up with the zoom level you selected in step 2!
I didn't test absolutely every method of closing the program, but this preference doesn't get saved if you stop it from Xcode (e.g., using Run|Stop menu item), and it doesn't get saved if your program terminates using exit. Closing it using the launcher is the only way I've found so far...