0

It doesn't seem like

transitionFromView:toView:duration:options:completion:

Handles memory like it indicates in the Apple docs. It is stated that the fromView is removed from the superview (implying a release) and the toView is added to the superview (implying a retain). Is this correct?

When I transition a view, later in my app when the view is actually presented I will get a BAD_ACCESS as the view was deallocated.

Any ideas? Thanks!


UPDATE:

Here is the code where the problem exists:

UIViewController *container = [[UIViewController alloc] init];
container.view.bounds = [UIScreen mainScreen].bounds;
[container.view setBackgroundColor:[UIColor blackColor]];

/* Deallocated in the finish callback */
tutorialViewController = [[TutorialViewController alloc] 
                          initWithNibName:@"TutorialViewController" 
                          bundle:nil];

tutorialViewController.tutorialDelegate = self;
[tutorialViewController loadTutorialData:data];

UINavigationController *nc = [[UINavigationController alloc] 
                              initWithRootViewController:tutorialViewController];
nc.navigationBar.barStyle = UIBarStyleBlackOpaque;

[UIView transitionFromView:[[window subviews] objectAtIndex:0]
                    toView:container.view
                  duration:kAnimationDuration
                   options:UIViewAnimationOptionTransitionCurlUp
                completion:nil];

[container presentModalViewController:nc animated:NO];

[container release];
[nc release];

If I do a [tutorialViewController release] at the bottom of this method, I will get the BAD_ACCESS. So it seems like the UINavigationController does not retain the root view controller.

P.S. The tutorialViewController was not a member variable previously, but I have now fixed this problem by simply releasing it after the view has been dismissed.

Maurizio
  • 4,143
  • 1
  • 29
  • 28

2 Answers2

1

You should check and confirm that you are not releasing the view yourself, hereby over-releasing. Or perhaps check the dealloc method for the view class which is being released to see if you're over-releasing anything in it.

runmad
  • 14,846
  • 9
  • 99
  • 140
0

The answer, after much testing, is simply that UINavigationViewController does not retain the view with initWithRootViewController. The Apple docs aren't clear on this.

Maurizio
  • 4,143
  • 1
  • 29
  • 28
  • Please view this question http://stackoverflow.com/questions/16337706/need-assistance-regarding-transitionfromviewtoviewdurationoptionscompletion/16338755?noredirect=1#16338755 – S.J May 03 '13 at 05:29