简体   繁体   English

transitionFromView:toView:duration:options:completion视图内存管理?

[英]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. 按照Apple文档中的指示处理内存。 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 ). 声明fromView已从fromView视图中删除(这意味着一个release ),而toView被添加到了toView视图(这意味着一个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. 当我转换视图时,稍后在我的应用中,当该视图实际呈现时,随着该视图的重新分配,我将得到一个BAD_ACCESS

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 . 如果在此方法的底部执行[tutorialViewController release] ,则将获得BAD_ACCESS So it seems like the UINavigationController does not retain the root view controller. 因此,似乎UINavigationController 没有保留根视图控制器。

PS 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. PS PSViewViewController以前不是成员变量,但是我现在通过在取消视图后简单地释放它来解决此问题。

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. 或者也许检查正在释放的视图类的dealloc方法,以查看是否过度释放了其中的任何内容。

The answer, after much testing, is simply that UINavigationViewController does not retain the view with initWithRootViewController . 经过大量测试,答案很简单,就是UINavigationViewController不会使用initWithRootViewController保留视图。 The Apple docs aren't clear on this. 苹果文档尚不清楚。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用transitionFromView:toView:duration:options:completion时,电影无法以横向模式正确显示,但使用addSubview时却可以 - Movie not being shown right in landscape mode when using transitionFromView:toView:duration:options:completion but does when using addSubview 动画的回调开始进行transitionFromView:toView:duration - Callback on animation start for transitionFromView:toView:duration UIView transitionFromView:toView 与两个 tableview 控制器 - 奇怪的位置错误 - UIView transitionFromView:toView with two tableview controllers - strange location bug 正确使用transitionFromViewController:toViewController:duration:options:animations:completion: - Proper usage of transitionFromViewController:toViewController:duration:options:animations:completion: 内存管理ARC和视图控制器 - Memory management ARC and view controllers 我们可以为UIView的transitionWithView传递多个选项:duration:options:animations:completion:method? - Can we pass multiple options for UIView's transitionWithView:duration:options:animations:completion: method? (iphone)uiimage,view,subviews memory management - (iphone) uiimage, view, subviews memory management 请帮忙:UINavigationController和视图控制器内存管理 - Please help: UINavigationController and view controllers memory management 在Modal View Controller中使用UINavigationController进行内存管理 - Memory Management with UINavigationController inside Modal View Controller 视图控制器中带有出口和属性的内存管理 - memory management with outlets and properties in view controllers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM