iOS – ViewController在ARC下popup时不被释放

我有一个UITabBarController作为我的主要基本视图控制器。 在第一个选项卡下,我有一个UINavigationController ,当然有一个与它关联的rootViewController ,称之为vcAvcA有一个button,它触发一个子视图控制器, vcB使用代码:

 [self performSegueWithIdentifier:@"PlacesDetailsSegue" sender:senderDictionary]; 

这似乎工作,我看到在仪器中,新的vcB分配正在发生。 当我popup视图控制器回vcA ,一切看起来工作,但似乎vcB从来没有释放(即,dealloc永远不会被调用)。 所以每次从vcA->vcB->vcA->vcB ,内存使用量都会增加。

我在vcB里面有一些实例variables,我在dealloc设置了所有的variables。 但是由于dealloc没有被解雇,他们从来没有被设置nil

我有一个引用self.view框架属性的[UIView animationWith...]块,但我已经pipe理,使用代码:

 __unsafe_unretained BBCategoryViewController *weakSelf = self; [UIView animateWithDuration:duration animations:^{ [_feedTableView setFrame:CGRectMake(0, _navBar.frame.size.height, weakSelf.view.frame.size.width, weakSelf.view.frame.size.height - kMenuBarHeight) ]; } completion:nil]; 

有没有人有任何想法如何我可以去找出什么对象仍然保留在一个VCBstream行?

作为参考,我的接口扩展是:

 @interface BBCategoryViewController () <UITableViewDataSource, UITableViewDelegate> { UITableView *_feedTableView; UIRefreshControl *_refreshControl; BBSearchBar *_searchBar; MKMapView *_mapView; BBNavigationBar *_navBar; NSString *_title; NSString *_categoryId; NSArray *_feedArray; } @end 

和我的dealloc(这是从来没有被解雇)是:

 -(void)dealloc { NSLog(@"Dealloc: BBCategoryViewController\n"); _feedTableView = nil; _refreshControl = nil; _searchBar = nil; _mapView = nil; _navBar = nil; _feedArray = nil; } 

更新:这实际上是由于子视图中的保留周期,而不是直接与视图控制器相关,因为我第一次想到。 Dan F 在这里引导了我正确的答案,以防有人跑过类似的东西。

您的vcB应该完全被释放,并且在您回弹到vcA时调用dealloc。 你必须在某个地方保持强烈的引用,否则你的“stream行”不正确。 如果你正在用segue这样做,这可能是你的问题 – segues不应该用于倒退(除了unwind segues)。 所以要么使用unwind segue,要么使用popViewControllerAnimated返回到vcA。 而且,在使用ARC时,不需要在dealloc中设置你的ivars为零。