Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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
Objective c 变量连接到界面生成器时没有释放内存,如何修复?_Objective C_Ios_Memory Management_Interface Builder - Fatal编程技术网

Objective c 变量连接到界面生成器时没有释放内存,如何修复?

Objective c 变量连接到界面生成器时没有释放内存,如何修复?,objective-c,ios,memory-management,interface-builder,Objective C,Ios,Memory Management,Interface Builder,当视图释放所有内存时,此视图控制器将消耗内存 如何释放记忆 @interface Agro01ViewController : UIViewController<UIScrollViewDelegate> { NSInteger picIndex; BOOL isOverrideing; NSTimer *myTimer; NSInteger maxPicture; } @property (nonatomic, retain) IBOutlet

当视图释放所有内存时,此视图控制器将消耗内存 如何释放记忆

@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];
}
@interface Agro01ViewController:UIViewController{
NSInteger-picIndex;
布尔异佛利定;
NSTimer*myTimer;
NSInteger-maxpoint;
}
@属性(非原子,保留)IBMOutlet UIScrollView*myscrollView;
@属性(非原子,保留)IBMOutlet UIScrollView*myscrollView3;
@属性(非原子,保留)IBUIView*simgView;
@属性(非原子,保留)ibuiview*simgView3;
@属性(非原子,保留)ibuiview*imgView;
@属性(非原子,保留)IBUIVIEW*imgView2;
@属性(非原子,保留)IBUIVIEW*imgView3;
@属性(非原子,保留)IBUIVIEW*imgView4;
@属性(非原子,保留)IBUIVIEW*imgView5;
@属性(非原子,保留)IBUIVIEW*imgView6;
@属性(非原子,保留)IBUIVIEW*imgView7;
@属性(非原子,保留)IBUIVIEW*imgView8;
@属性(非原子,保留)IBUIView*纵向;
@地产(非原子,保留)IBUIVIEW*景观;
@属性(非原子)NSInteger maxPicture;
-(iAction)关闭按钮:(id)发送器;
-(无效)更新结构;
-(iAction)SecondViewbutton:(id)发送者;
@结束
@视图控制器的实现
@综合imgView=\u imgView,imgView 2=\u imgView 2,imgView 3=\u imgView 3,imgView 4=\u imgView 4,imgView 5=\u imgView 5;
@综合imgView6=_imgView6,imgView7=_imgView7,imgView8=_imgView8,纵向=_纵向,横向=_横向;
@综合myscrollView=\u myscrollView,myscrollView3=\u myscrollView3,simgView=\u simgView,simgView 3=\u simgView,maxPicture;
-(无效)解除锁定{
NSLog(@“dealoc”);
[_景观发布];
[_肖像发布];
[_imgView发布];
[_imgView2发布];
[_imgView3发布];
[_imgView4发布];
[_imgView5发布];
[_imgView6发布];
[_imgView7发布];
[_imgView8发布];
[_myscrollView发布];
[_myscrollView3发布];
[_simgView发布];
[_simgView3发布];
[super dealoc];
}
-(无效)视图卸载{
self.simgView=nil;
self.simgView3=nil;
self.myscrollView=nil;
self.myscrollView3=nil;
自我景观=零;
自画像=零;
self.imgView=nil;
self.imgView2=nil;
self.imgView3=nil;
self.imgView4=nil;
self.imgView5=零;
self.imgView6=零;
self.imgView7=nil;
self.imgView8=零;
[超级视频下载];
}
-(无效)viewDidLoad{
if(([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationAndscapeLeft)| |([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationAndscapeRight)){
self.Landscape.alpha=1;
self.trait.alpha=0;
}
否则{
self.scape.alpha=0;
self.grait.alpha=1;
}
[self.view addSubview:self.scape];
[self.view addSubview:self.grait];
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=是;
self.myscrollView3.delegate=self;
self.myscrollView3.showshorizontalscrolindicator=NO;
self.myscrollView3.showsVerticalScrollIndicator=否;
[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=是;
self.myscrollView.delegate=self;
self.myscrollView.showshorizontalscrolindicator=NO;
self.myscrollView.showsVerticalScrollIndicator=否;
[self.myscrollView addSubview:self.simgView];
Isoverriding=否;
picIndex=0;
[超级视图下载];
}
摆脱:

- (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];
}
您正在清除指向要删除的对象的指针,然后才能进行dealloc。让Dealoc来处理吧


谢谢你。我正在删除它,让我测试一下如果修复了它,正确的解决方案是确保您的属性定义为
retain
。上面的代码是正确的,应该是
viewDidUnload
的一部分。乔,内存仍然没有空闲。有什么解决方案吗?Rob Napier,我已将其更改为保留,但我不知道当此视图已解除锁定时,内存为何不可用OK,我没有注意到您正在使用访问器处理引用。所以Rob将它们设置为nil(使用访问器)将释放对象是正确的。但是,我不确定你接到这些电话的时间。这在ViewController中,因此只有在释放ViewController时才会调用dealloc。viewDidUnload将在视图发布时被调用,用于清理与已发布视图关联的所有属性。那是哪一个呢?发生了什么让你期待内存被释放?