我们不分配基于 nib 的 View ,因此当我们从 bundle 中获取 View 时似乎没有必要释放它们。我有一个场景,我有从 nib 制作的自定义单元格。即使我释放包含 UITableView 单元格的 tableview单元格对象保留在内存中。我没有在其他任何地方保留它。如果有任何答案,我将不胜感激
最佳答案
当您从包中获取对象时,它会将其分配给 IBOutlet 实例变量。您需要按照通常的方式释放 dealloc 中的实例。我是这样做的,
in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//get a new cell instance from the xib
[[NSBundle mainBundle] loadNibNamed:@"ASEventTableViewCell" owner:self options:nil];
//get the object from the outlet
cell = [self eventsTableViewCell];
The in viewDidUnload,
self.eventsTableViewCell=nil;
And dealloc
[eventsTableViewCell release];
关于iphone - nib 中的自定义单元格何时发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4656001/