简体   繁体   中英

popToRootViewControllerAnimated crashes App in Xcode5 on IOS 7 sim

I have an issue with upgrading to Xcode5. Before I even set about changing anything in my project I thought I would build and run it with the IOS7 3.5inch Simulator. There are two major issues and this is the main one that I cannot figure out. I have identified a line of code that has always worked perfectly until now - now whenever it runs my app crashes with an EXC_BAD_ACCESS I've traced it to a single line of code which is my popToRoot - basically at the end of filling out a form and saving it I want to reset the view to defaults which is what I have successfully used this line of code for until now.

The code looks like this:

[self.navigationController popToRootViewControllerAnimated:NO];

With some NSLog'ing in it looks like this:

NSLog(@" self.navCon is %@", self.navigationController);
                NSArray *myControllers = self.navigationController.viewControllers;
                NSLog(@"myControllers Content is %@", myControllers);
                NSLog(@"myControllers Count is %i", myControllers.count);
                [self.navigationController popToRootViewControllerAnimated:NO];

And my log out put looks like this:

2013-11-10 00:21:32.480 trainForTri copy[9552:a0b]  self.navCon is <UINavigationController: 0xb5bf580>
2013-11-10 00:21:32.481 trainForTri copy[9552:a0b] myControllers Content is (
    "<SGK_T4T_01SecondViewController: 0xbaeac00>",
    "<AddSessionSessTypePicker: 0xb5e51e0>",
    "<SGK_T4T_01SecondViewController: 0xbb5fa00>"
)

I have noticed that the 1st and 3rd viewControllers in my viewController array are the same view, but then why has it worked on all OS's until now? And more importantly any ideas on how I can fix this?

have you used arc ? check your summary settings in xcode 5.anything can be changed. problem with released object of your view controller

Please see if you are following these points:

  1. Before calling popToRootViewControllerAnimated: confirm that the RootViewController does actually exist. If it died somewhere along the line, calling the method will cause a crash.
  2. Check the – viewWillDisappear: and – viewDidDisappear: methods of your last view to make sure you're not doing something dangerous there.
  3. Check the dealloc method of the views and their controllers to make sure your not over-releasing something.
  4. Try to use NSZombie and find out the over-released object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM