【发布时间】:2011-07-11 11:12:47
【问题描述】:
由于我认为我最近的另一篇帖子 (Memory management when adding a UIImageView to another viewController's view from another viewController's view) 吓跑了所有人,而且我的时间不多了,所以我想用更简单的方式问这个问题。如果您想知道我正在做的更多细节,请参阅另一篇文章。
在将 UIImageView 添加到另一个 windows 视图时,如何管理内存和释放?
即我正在一个视图中创建 UIImageView,并将其作为子视图添加到另一个 Windows 视图中。电视正在使用另一个窗口。
现在我有:
mapImageViewEx = [[UIImageView alloc] init];
// I think you can ignore these two things below
CGPoint p = mapScrollView.contentOffset;
mapImageViewEx.frame = CGRectMake((p.x*-1), (p.y*-1), mapImageView.frame.size.width, mapImageView.frame.size.height);
NSString *mapExFileLocation = [[NSBundle mainBundle] pathForResource:[map_List objectAtIndex:mapNum] ofType:@"png"];
NSData *mapExIMGData = [NSData dataWithContentsOfFile:mapExFileLocation];
mapImageViewEx.image = [UIImage imageWithData:mapExIMGData];
// finds the other window's view controller's view
UIView *containerExViewP = (UIView*)[del.switchExVC.view viewWithTag:9000];
// adds it
[containerExViewP addSubview:mapImageViewEx];
我遇到的问题是,每次我退出视图时,它都会不断累积内存使用量。在 iPad 屏幕视图的 dealloc 中释放图像没有任何作用。
【问题讨论】:
标签: iphone ipad memory uiimageview screen