【发布时间】:2012-03-21 21:35:41
【问题描述】:
我在这里有点修复。应用程序搜索 Core Data 并将其呈现在屏幕上,使用 50 多个新的 UIViewController 子类添加到当前视图。当新的搜索出现时,这些 VC 将从视图中删除并应该被释放。但是,我不保留对 VC 的引用。
我尝试使用保留它们的数组,但这似乎不起作用。遇到这种事怎么办?
for (UIView *view in scrollView.subviews) {
[view removeFromSuperview];
}
[gridVCs removeAllObjects];
int numItems = [searchResults count];
int n = 0;
for(Plant *plant in searchResults)
{
GridViewCellController *gridVC = [[GridViewCellController alloc] initWithNibName:@"GridViewCellController" bundle:nil]; // !!! XXX
[gridVC setPlant:plant];
[gridVC setSearchVC:self];
gridVC.label.text = plant.naamnl;
[gridVC.imageView setImage:[UIImage imageWithContentsOfFile:foto_url]];
[scrollView addSubview:gridVC.view];
[gridVCs addObject:gridVC];
n++;
}
非常感谢任何帮助!
【问题讨论】:
标签: objective-c memory-management uiviewcontroller