0
votes

I have navigation application. I have created a UINavigationController in application didFinishLaunchingWithOptions of appdelegate. self.initialviewcontroller = [[InitialViewController alloc] initWithNibName:@"InitialViewController" bundle:nil]; UINavigationController *myNavController = [[UINavigationController alloc] initWithRootViewController:self.initialviewcontroller];

self.window.rootViewController = myNavController; [self.window makeKeyAndVisible];

In the InitialViewController i have button which will navigate to SecondViewController. So, in the IBAction of button i push the SecondViewController as follows,

if(self.secondView != nil)
  self.secondView = nil;
self.secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.navigationController pushViewController:self.secondView animated:YES];

Situation : The navigation is working fine, i am bale to navigate between InitialViewController to SecondViewController. When i am in SecondViewController and press home button of device, the application is entered into background and when i reopen the app it opens the app from where i closes(i.e SecondViewController). Now if i press the back button to go to InitialViewController, the app is crashing.

It's working fine in the ios simulator,but crashes occurs on devices.

I didn't understand what the mistake i have done. Please let me know any idea. Thanks in advance....

1
What is the OS version of your device? As you might seen on the documentation, dismissModalViewControllerAnimated on iOS6. Use dismissViewControllerAnimated:completion: instead. - johnoodles
iOS 6? and i am developing the app in ios 4.3 - AshokReddy Kalvapalli

1 Answers

0
votes

Try dissmissing your view controller using

[self dismissModalViewControllerAnimated:YES];

It works for me. Even for iOS 6.