tags:

views:

598

answers:

1

My iPhone app initiates a phone call with:

NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", @"11111111"]];
[[UIApplication sharedApplication] openURL:phoneURL];

This is from a UIView inside a UINavigationController. It is not the root UIView however.

When the phone app is finished with the call and returns control to my app, the screen that the user is returned to is not the screen that the user left. It is the root screen of the UINavigationController.

How do I get [UIApplication sharedApplication] to return control at the screen that the user left?

+2  A: 

You don't.

If you insert appropriate debugging code, I think you'll find that your app actually closes when the call is placed and reopens when the call ends. This is by design; resources are limited in mid-call, and Apple doesn't want to have to decide between dropping the call and killing your app. So what you need to do is save the application's state before exiting (either as you go or in applicationWillTerminate:) and then restore it in applicationDidFinishLaunching:. Fortunately, you need to do this anyway--iPhone apps should always restore to their previous state when you relaunch them--so this isn't really extra work.

Brent Royal-Gordon