我已經在此處發佈此內容之前搜索了最好的內容。下面是導致內存泄漏的代碼。包括autorelease修復了內存泄漏,但我更感興趣知道我在這裏做錯了什麼。如果我擁有它,我應該釋放它,這是我想要做的:) THankyou提前的幫助。 ContainerView是一個UIView,我將其歡迎文本添加到它。正在發佈UIImageView,並且仍然發生內存泄漏
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];
「包括autorelease修復內存泄漏」,是否意味着您正在autoreleasing圖像視圖並調用它的發佈? (BTW,搞笑圖片名稱) – Merky 2011-03-29 18:34:40