0
這個視圖控制器會消耗內存,當視圖釋放所有內存不空閒時 如何釋放內存?變量連接到Interface Builder時釋放內存不釋放時,如何修復?
@interface Agro01ViewController : UIViewController<UIScrollViewDelegate> {
NSInteger picIndex;
BOOL isOverrideing;
NSTimer *myTimer;
NSInteger maxPicture;
}
@property (nonatomic, retain) IBOutlet UIScrollView *myscrollView;
@property (nonatomic, retain) IBOutlet UIScrollView *myscrollView3;
@property (nonatomic, retain) IBOutlet UIView *simgView;
@property (nonatomic, retain) IBOutlet UIView *simgView3;
@property (nonatomic, retain) IBOutlet UIView *imgView;
@property (nonatomic, retain) IBOutlet UIView *imgView2;
@property (nonatomic, retain) IBOutlet UIView *imgView3;
@property (nonatomic, retain) IBOutlet UIView *imgView4;
@property (nonatomic, retain) IBOutlet UIView *imgView5;
@property (nonatomic, retain) IBOutlet UIView *imgView6;
@property (nonatomic, retain) IBOutlet UIView *imgView7;
@property (nonatomic, retain) IBOutlet UIView *imgView8;
@property (nonatomic, retain) IBOutlet UIView *Portrait;
@property (nonatomic, retain) IBOutlet UIView *Landscape;
@property (nonatomic) NSInteger maxPicture;
- (IBAction) Closebutton:(id)sender;
- (void)updatepicture;
- (IBAction) SecondViewbutton:(id)sender;
@end
@implementation Agro01ViewController
@synthesize imgView = _imgView, imgView2 = _imgView2, imgView3 = _imgView3, imgView4 = _imgView4, imgView5 = _imgView5;
@synthesize imgView6 = _imgView6, imgView7 = _imgView7, imgView8 = _imgView8, Portrait = _Portrait, Landscape = _Landscape ;
@synthesize myscrollView = _myscrollView, myscrollView3 = _myscrollView3, simgView = _simgView, simgView3 = _simgView3, maxPicture;
- (void)dealloc {
NSLog(@"dealloc");
[_Landscape release];
[_Portrait release];
[_imgView release];
[_imgView2 release];
[_imgView3 release];
[_imgView4 release];
[_imgView5 release];
[_imgView6 release];
[_imgView7 release];
[_imgView8 release];
[_myscrollView release];
[_myscrollView3 release];
[_simgView release];
[_simgView3 release];
[super dealloc];
}
- (void)viewDidUnload {
self.simgView = nil;
self.simgView3 = nil;
self.myscrollView = nil;
self.myscrollView3 = nil;
self.Landscape = nil;
self.Portrait = nil;
self.imgView = nil;
self.imgView2 = nil;
self.imgView3 = nil;
self.imgView4 = nil;
self.imgView5 = nil;
self.imgView6 = nil;
self.imgView7 = nil;
self.imgView8 = nil;
[super viewDidUnload];
}
- (void)viewDidLoad {
if (([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight)) {
self.Landscape.alpha = 1;
self.Portrait.alpha = 0;
}
else {
self.Landscape.alpha = 0;
self.Portrait.alpha = 1;
}
[self.view addSubview:self.Landscape];
[self.view addSubview:self.Portrait];
self.myscrollView3.contentSize = CGSizeMake(self.simgView3.frame.size.width, self.simgView3.frame.size.height);
self.myscrollView3.maximumZoomScale = 1.0;
self.myscrollView3.minimumZoomScale = 1.0;
self.myscrollView3.clipsToBounds = YES;
self.myscrollView3.delegate = self;
self.myscrollView3.showsHorizontalScrollIndicator = NO;
self.myscrollView3.showsVerticalScrollIndicator = NO;
[self.myscrollView3 addSubview:self.simgView3];
self.myscrollView.contentSize = CGSizeMake(self.simgView.frame.size.width, self.simgView.frame.size.height);
self.myscrollView.maximumZoomScale = 1.0;
self.myscrollView.minimumZoomScale = 1.0;
self.myscrollView.clipsToBounds = YES;
self.myscrollView.delegate = self;
self.myscrollView.showsHorizontalScrollIndicator = NO;
self.myscrollView.showsVerticalScrollIndicator = NO;
[self.myscrollView addSubview:self.simgView];
isOverrideing = NO;
picIndex = 0;
[super viewDidLoad];
}
謝謝。我正在刪除它,讓我測試 – RAGOpoR
如果解決了這個問題,正確的解決方案是確保您的屬性被定義爲'retain'。上面的代碼是正確的,應該是'viewDidUnload'的一部分。 –
喬,記憶仍然不是免費的。任何解決方案 – RAGOpoR