0

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....

2
  • 1
    What is the OS version of your device? As you might seen on the documentation, dismissModalViewControllerAnimated on iOS6. Use dismissViewControllerAnimated:completion: instead. Commented Nov 20, 2012 at 5:09
  • iOS 6? and i am developing the app in ios 4.3 Commented Nov 20, 2012 at 5:16

1 Answer 1

0

Try dissmissing your view controller using

[self dismissModalViewControllerAnimated:YES];

It works for me. Even for iOS 6.

Sign up to request clarification or add additional context in comments.

1 Comment

What is your code for the back button to go to InitialViewController ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.