我有一個非常大的圖像IntroViewController,這增加了我的應用程序的內存大約1.5MB。該圖像設置在視圖控制器的NIB中的UIImageView上。我的應用程序如何在內存中顯示圖像?
一旦介紹完成後,我會在IntroViewController上調用release
,然後它自己成功調用dealloc
並在大型UIImageView上調用release
。然而,我在樂器中的記憶似乎沒有再次回落。我可以通過將圖像重命名爲NIB中的UIImageView來測試內存差異,以便找不到任何內容,然後內存下降大約1.5MB。
那麼,爲什麼我不能回憶那些回憶呢?是否有什麼,我想念正在停止UIImageView正確dealloc'd?
感謝,
:-Joe
-------增加:CODE ------
#import <UIKit/UIKit.h>
@class AppDelegate_iPhone;
@interface IntroViewController : UIViewController
{
AppDelegate_iPhone *appDelegate;
UIImageView *wheelImageView;
UIView *copyOverlayView;
}
@property (nonatomic, retain) IBOutlet UIImageView *wheelImageView;
@property (nonatomic, retain) IBOutlet UIView *copyOverlayView;
- (void)startAnimation;
@end
@implementation IntroViewController
@synthesize wheelImageView, copyOverlayView;
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate];
[self startAnimation];
}
- (void)viewDidDisappear:(BOOL)animated
{
[self.wheelImageView removeFromSuperview];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
[super viewDidUnload];
self.wheelImageView.image = nil;
appDelegate = nil;
}
- (void)dealloc
{
[wheelImageView release];
[copyOverlayView release];
[super dealloc];
}
- (void)startAnimation
{
self.wheelImageView.transform = CGAffineTransformMakeScale(0.5, 0.5);
[UIView beginAnimations:@"wheelScale" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wheelScaleDidFinish)];
self.wheelImageView.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView commitAnimations];
[UIView beginAnimations:@"copyOverlayFade" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelay:1.0];
self.copyOverlayView.alpha = 0;
[UIView commitAnimations];
}
- (void)wheelScaleDidFinish
{
[appDelegate introAnimationFinished];
}
@end
----編輯
燦任何人都請幫忙?我很難過,這導致我的應用程序崩潰在iPhone上由於高內存:(無法弄清楚如何擺脫愚蠢的形象!Grrrr ...
原因是UIImage imageNamed:和朋友維護一個圖片緩存。在壓力下,系統將釋放內存。 – 2010-08-28 07:05:50
所以雖然有autorelease,但有些對象有自己的緩存?這是一個鮮爲人知的事實,謝謝。但是,你說在壓力下系統會釋放內存,但在實踐中,對於我來說,手機會因內存不足而崩潰,並且泄漏仍會顯示緩存的圖像! – jowie 2010-08-28 12:17:55