переменная, подключенная к Интерфейсному строителю, не освобождает память при ее освобождении, как исправить? - PullRequest
0 голосов
/ 18 августа 2011

этот контроллер представления потребляет память, когда представление освобождает всю эту память, как свободна, как освободить эту память ??

@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];
}

1 Ответ

0 голосов
/ 18 августа 2011

Избавиться от:

- (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];
}

Вы очищаете указатели на объекты, от которых хотите избавиться, до того, как сделка может быть осуществлена. Пусть справится с деллоками.

Джо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...