iOS4 multitasking: subtle UIViewController change

August 31st, 2010 § 0 comments

UIApplicationDelegate changed a lot with the introduction of multitasking in iOS4 (see Dr. Touch’s post and charts [although there are still some small omissions and inaccuracies there]).

But UIApplicationDelegate was not the only class affected. UIViewController‘s behaviour is slightly changed in the presence of multitasking: namely the view(Will|Did)Disappear: methods.

If your iOS4-built app is running on iPhone OS 3, or if UIApplicationExitsOnSuspend is set to true, then when the user presses the Home button, the frontmost view controller’s viewWillDisappear: and viewDidDisappear: methods will be called before the app exits. However, if UIApplicationExitsOnSuspend is false and you’re running on a multitasking-enabled device (iPhone 3GS or higher; iPod touch 3rd generation), viewWillDisappear: and viewDidDisappear: are not called as it enters the background.

That was a messy couple of sentences so here’s a chart!

UIApplication­Exits­On­Suspend? multitasking-capable device and OS? When Home button is pressed:
false true viewWill/DidDisappear: NOT called
false false viewWill/DidDisappear: IS called
true true viewWill/DidDisappear: IS called
true false viewWill/DidDisappear: IS called

It’s subtle, but it might make a difference to your code.

Tagged ,

Leave a Reply

Your email address will not be published. Required fields are marked *

What's this?

You are currently reading iOS4 multitasking: subtle UIViewController change at bunnyhero dev.

meta