Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 正在释放UIImageView,但仍然存在内存泄漏_Iphone_Memory Leaks_Uiimageview - Fatal编程技术网

Iphone 正在释放UIImageView,但仍然存在内存泄漏

Iphone 正在释放UIImageView,但仍然存在内存泄漏,iphone,memory-leaks,uiimageview,Iphone,Memory Leaks,Uiimageview,我已经尽了最大的努力才把这个贴在这里。下面是导致内存泄漏的代码。包括自动释放修复了内存泄漏,但我更感兴趣的是知道我在这里做错了什么。如果我拥有它,我应该释放它,这就是我试图做的:) 提前谢谢你的帮助。ContainerView是一个UIView,我正在向它添加我的欢迎文本 UIImageView *welcomeText = [[UIImageView alloc] init]; welcomeText = [[UIImageView alloc] initWithFrame:CGRectZer

我已经尽了最大的努力才把这个贴在这里。下面是导致内存泄漏的代码。包括自动释放修复了内存泄漏,但我更感兴趣的是知道我在这里做错了什么。如果我拥有它,我应该释放它,这就是我试图做的:) 提前谢谢你的帮助。ContainerView是一个UIView,我正在向它添加我的欢迎文本

UIImageView *welcomeText = [[UIImageView alloc] init];
welcomeText = [[UIImageView alloc] initWithFrame:CGRectZero];
welcomeText.frame = (CGRect) {  CGRectGetMidX(containerView.frame) -295 , 100.0, 590,134 };
welcomeText.autoresizingMask =  UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | 
        UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
welcomeText.image = [UIImage imageNamed:@"welcome-to-the-jungle.png"];
[containerView addSubview:welcomeText];
[welcomeText release];
UIImageView*welcomeText=[[UIImageView alloc]init]; welcomeText=[[UIImageView alloc]initWithFrame:cRectZero]; 在之前分配的第二行之后,welcomeText将丢失,并且您正在泄漏该内存。在第1行之后,图像视图被分配,welcomeText指向该视图。在第二行中,另一个图像视图被分配,现在welcomeText指向这个新视图。所以,您没有任何指向第一个alloced image view的指针,因此,它被泄漏了

这里你实际上不需要第1行

UIImageView *welcomeText = [[UIImageView alloc] initWithFrame:CGRectZero]; UIImageView*welcomeText=[[UIImageView alloc]initWithFrame:cRectZero]; UIImageView*welcomeText=[[UIImageView alloc]init]; welcomeText=[[UIImageView alloc]initWithFrame:cRectZero]; 在之前分配的第二行之后,welcomeText将丢失,并且您正在泄漏该内存。在第1行之后,图像视图被分配,welcomeText指向该视图。在第二行中,另一个图像视图被分配,现在welcomeText指向这个新视图。所以,您没有任何指向第一个alloced image view的指针,因此,它被泄漏了

这里你实际上不需要第1行

UIImageView *welcomeText = [[UIImageView alloc] initWithFrame:CGRectZero];
UIImageView*welcomeText=[[UIImageView alloc]initWithFrame:cRectZero] 不能在第一行中分配UIImageView对象。在第二行中,第一行中分配的对象泄漏。

不能在第一行中分配UIImageView对象。在第二行中,第一行中分配的对象泄漏。

“包括自动释放修复内存泄漏”,您的意思是自动释放图像视图并对其调用释放吗?(顺便说一句,有趣的图片名称)“包括自动释放修复内存泄漏”,你的意思是你正在自动释放图像视图并调用它的释放?(顺便说一句,有趣的图片名称)