UITableView内存错误

UITableView内存错误,uitableview,Uitableview,UITableView中存在内存泄漏问题。如果我在DetailViewController表的底部,并且我想返回MasterViewController,我会崩溃。如果使用UITableViewController,则不会发生崩溃 AppDelegate 主视图控制器 详细视图控制器 如果我在DetailViewController dealloc中将_table.view.delegate设置为nil,则错误已修复。但我不明白为什么只有当底部的表。应用程序尝试调用scrollViewDidSc

UITableView中存在内存泄漏问题。如果我在DetailViewController表的底部,并且我想返回MasterViewController,我会崩溃。如果使用UITableViewController,则不会发生崩溃

AppDelegate

主视图控制器

详细视图控制器


如果我在DetailViewController dealloc中将_table.view.delegate设置为nil,则错误已修复。但我不明白为什么只有当底部的表。应用程序尝试调用scrollViewDidScroll:,但DetailViewController被解除分配时才会发生这种情况。NSZombie有助于理解这一点。
_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor blackColor];
_window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[MasterViewController alloc] init]];
[_window makeKeyAndVisible];
- (void)viewDidAppear:(BOOL)animated {
     [super viewDidAppear:animated];
     DetailViewController *detailViewController = [[DetailViewController alloc] init];
     [self.navigationController pushViewController:detailViewController animated:YES];
}
@interface DetailViewController ()
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.rowHeight = 60;
    [self.view addSubview:_tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 30;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    return cell;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSLog(@"scrollViewDidScroll");
}

@end