Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.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_Ipad_Memory Management - Fatal编程技术网

Objective c 而改变方向的记忆却在增加

Objective c 而改变方向的记忆却在增加,objective-c,ios,ipad,memory-management,Objective C,Ios,Ipad,Memory Management,很抱歉问这个基本问题。在我的viewcontroller中,当我旋转我的设备时,内存会增加,以防止我用@property和@synthesis修改了我的所有IBoutlet,即使它也不工作,我的分配也会达到峰值。我不知道我在didrotate方法中犯了什么错误,我提供了下面的代码。我只是在修改我的图像和我的IBOutlets的框架。下面提供的代码有错误吗 -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromIn

很抱歉问这个基本问题。在我的viewcontroller中,当我旋转我的设备时,内存会增加,以防止我用@property和@synthesis修改了我的所有IBoutlet,即使它也不工作,我的分配也会达到峰值。我不知道我在didrotate方法中犯了什么错误,我提供了下面的代码。我只是在修改我的图像和我的IBOutlets的框架。下面提供的代码有错误吗

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
            if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation)){
                for(UIImageView *thumbImage in [tableSupportView subviews]){
                        UIImage *tempImage=[bookListDataSource bookAtIndex:thumbnilIndex].titleImage;
                        CGFloat thumbnilHeight=95*((float) tempImage.size.height/tempImage.size.width);
                        thumbImage.frame=CGRectMake(thumbnilIndex*125, (205-thumbnilHeight)/2, 95, thumbnilHeight);
                        thumbnilIndex++;
                }
                self.myoutlets.frame=cgrect(frames according to criteria);
                NSString *detailImagePath=[[NSBundle mainBundle] pathForResource:@"details_bg_nb" ofType:@"png"];
                UIImage *detailImage=[[UIImage alloc] initWithContentsOfFile:detailImagePath];
                UIColor *bookDetailViewColor=[[UIColor alloc] initWithPatternImage:detailImage];
                self.bookDetailView.backgroundColor=bookDetailViewColor;
                [bookDetailViewColor release];
                [detailImage release];
                NSString *listBGImagePath=[[NSBundle mainBundle] pathForResource:@"list_bg_nb" ofType:@"png"];
                UIImage *listBGImage=[[UIImage alloc] initWithContentsOfFile:listBGImagePath];
                UIColor *listHeaderContainerViewColor=[[UIColor alloc] initWithPatternImage:listBGImage];
                self.listHeaderContainerView.backgroundColor=listHeaderContainerViewColor;
                [listHeaderContainerViewColor release];
                [listBGImagePath release];

                NSString *listBandPath=[[NSBundle mainBundle] pathForResource:@"listband_potrait" ofType:@"png"];
                UIImage *listBand=[[UIImage alloc] initWithContentsOfFile:listBandPath];
                self.categoryBrandingImageView.image=listBand;
                [listBand release];
            }else {
                NSUInteger thumbnilIndex=0;
                NSUInteger numberOfBooks=[bookListDataSource numberOfBooks];
                for(UIImageView *thumbImage in [tableSupportView subviews]){
                        UIImage *tempImage=[bookListDataSource bookAtIndex:thumbnilIndex].titleImage;
                        CGFloat thumbnilHeight=85*((float) tempImage.size.height/tempImage.size.width);
                        thumbImage.frame=CGRectMake(thumbnilIndex*115, (CGRectGetHeight(tableSupportView.frame)-thumbnilHeight)/2.0, 85, thumbnilHeight);
                        thumbnilIndex++;
                    }
                }
            self.myoutlets.frame=cgrectmake(my custom frame);
                NSString *detailImagePath=[[NSBundle mainBundle] pathForResource:@"landscape_details_bg_nb" ofType:@"png"];
                UIImage *detailImage=[[UIImage alloc] initWithContentsOfFile:detailImagePath];
                UIColor *bookDetailViewColor=[[UIColor alloc] initWithPatternImage:detailImage];
                self.bookDetailView.backgroundColor=bookDetailViewColor;
                [bookDetailViewColor release];
                [detailImage release];

                NSString *listBGImagePath=[[NSBundle mainBundle] pathForResource:@"landscape_list_bg_nb" ofType:@"png"];
                UIImage *listBGImage=[[UIImage alloc] initWithContentsOfFile:listBGImagePath];
                UIColor *listHeaderContainerViewColor=[[UIColor alloc] initWithPatternImage:listBGImage];
                self.listHeaderContainerView.backgroundColor=listHeaderContainerViewColor;
                [listHeaderContainerViewColor release];
                [listBGImagePath release];

                NSString *listBandPath=[[NSBundle mainBundle] pathForResource:@"listband_landscape" ofType:@"png"];
                UIImage *listBand=[[UIImage alloc] initWithContentsOfFile:listBandPath];
                self.categoryBrandingImageView.image=listBand;
                [listBand release];
            }
            self.bookInformation.backgroundColor=[UIColor clearColor];
            self.bookDescrption.backgroundColor=[UIColor clearColor];
        }
    }

如果存在任何泄漏,请向我提供解决方案。提前感谢。

在这部分代码中,您有一个错误-

NSString *listBGImagePath=[[NSBundle mainBundle] pathForResource:@"landscape_list_bg_nb" ofType:@"png"];
UIImage *listBGImage=[[UIImage alloc] initWithContentsOfFile:listBGImagePath];
UIColor *listHeaderContainerViewColor=[[UIColor alloc] initWithPatternImage:listBGImage];
self.listHeaderContainerView.backgroundColor=listHeaderContainerViewColor;
[listHeaderContainerViewColor release];
[listBGImagePath release];
您必须释放
listBGImage
而不是
listbgimapath