我有一个UITabBarController作为我的主要基础视图控制器。在第一个选项卡下,我有一个UINavigationController当然有rootViewController与之关联的,称为它vcA。vcA有一个触发子视图控制器的按钮,vcB使用代码:
[self performSegueWithIdentifier:@"PlacesDetailsSegue" sender:senderDictionary];
这似乎可行,我在工具中看到正在发生新的 vcB 分配。当我将视图控制器弹回 时vcA,一切看起来都正常,但似乎 vcB 从未被释放(即,从未调用 dealloc)。因此,每次 go from vcA->vcB->vcA->vcB,内存使用量都会增加和增加。
我在里面有一些实例变量vcB,所有这些我都设置nil在dealloc. 但由于 dealloc 没有被解雇,它们实际上从未设置为nil.
我确实有一个[UIView animationWith...]引用 的框架属性的块self.view,但我已经使用代码进行了管理:
__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];
有谁知道我如何才能找出哪些对象仍保留在 vcB pop 上?
作为参考,我的接口扩展是:
@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在这里引导我找到正确答案,以防有人遇到类似的情况。