0
我添加自定义视图与下面的代码tableHeaderView:内存泄漏在哪里?
imageButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
imageButton.frame = CGRectMake(120, 12, 64, 64);
imageButton.titleLabel.font = [UIFont systemFontOfSize:10];
imageButton.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
imageButton.titleLabel.textAlignment = UITextAlignmentCenter;
[imageButton setTitle:NSLocalizedString(@"Choose\nPhoto", @"Choose\nPhoto") forState:UIControlStateNormal];
[imageButton addTarget:self action:@selector(photoButtonPressed) forControlEvents:UIControlEventTouchUpInside];
// add existing image, if any, to button
if (child.thumbnailImage != nil) {
[imageButton setBackgroundImage:child.thumbnailImage forState:UIControlStateNormal];
}
// add button to view
self.headerView = [[UIView alloc] initWithFrame:CGRectMake(22, 12, 70, 70)];
[headerView addSubview:imageButton];
// add view to table header
self.tableView.tableHeaderView = headerView;
内存泄漏是显示在上述用于headerView的UIView的ALLOC线。 我声明UIView和UIButton在头文件中,并在ViewDidUnload和dealloc中释放它,所以我不知道我在做什么错了。 此外,这只是显示在设备上,而不是模拟器(只是想我会提到)。
任何帮助,将不胜感激。
感谢,
杆
您可以发布您ViewDidUnload? – xil3 2010-11-16 08:21:50