Search code examples
iphoneobjective-cxcodexcode4

When I press home button on iPhone, my app minimizes instead of close


When I press home button, my app minimizes instead of close. When I launch it again, the app launches the last view controller I was on it, instead of return to first view controller. This is my storyboard:

-> A -> B -> C

When pressing home in "C" and launching it again, app stays on "C" instead of "A"

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [super dealloc];
}
- (void)viewDidUnload {
    [self setEmail:nil];
    [super viewDidUnload];
}

Solution

  • When you close the app, it doesn't KILL it, it just suspends it. Unless you set the option to kill it when you close it.

    Go to the settings in your .plist and set

    Application does not run in background to YES

    This is also the UIApplicationExitsOnSuspend key

    Also, please read the Apple Documentation For Application Flow