开发者

transitionFromView:toView:duration:options:completion view memory management?

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 a开发者_开发技巧lloc] 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜