2012-02-21 31 views
0

遺憾地詢問基本question.In我的視圖 - 控制記憶是怎麼回事,當我轉動我的設備,以防止我修改了所有IBOutlets與@property和@synthesize甚至還沒有工作還是我的配置是去峯,我不知道我在我提供我的代碼below.Here我只是修改我的圖片和框架我IBOutlets.Is有什麼錯在下面提供的代碼didrotate方法做了什麼錯?而朝向改變內存增加

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

如果有任何泄漏請提供給我解決方案。感謝提前。

+2

的代碼,蝙蝠俠聖塊! – 2012-02-21 08:07:54

回答

1

在這部分代碼,你有一個錯誤 -

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而不是listBGImagePath

+0

它出現兩次。 – beryllium 2012-02-21 08:12:28

+0

+1謝謝beryllium.I同意我的錯誤。 – ajay 2012-02-21 09:09:30