2011-07-08 14 views
0

ビルドと分析の結果この行が表示されます。UITableViewcellメモリリーク

ライン923に割り当てられたオブジェクトの潜在的な漏れと「セル」に格納

これは使用IAMのコードです。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 


CustomizedCell *cell =(CustomizedCell*) [tableView dequeueReusableCellWithIdentifier:@"CustomizedCell"]; 

HolidayAppDelegate *delegatObj = (HolidayAppDelegate *)[UIApplication sharedApplication].delegate; 

NSLog(@"cellForRowAtIndexPath %d",indexPath.row); 
if (cell == nil) { 


    cell = [[CustomizedCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"CustomizedCell"]; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 



    [cell.mainBtn addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.redBtn addTarget:self action:@selector(Fourthbuttonclick:) forControlEvents:UIControlEventTouchUpInside]; 
[cell.greenBtn addTarget:self action:@selector(Firstbuttonclick:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.bluebtn addTarget:self action:@selector(Secondbuttonclick:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.yellowbtn addTarget:self action:@selector(Thirdbuttonclick:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.blackbtn addTarget:self action:@selector(Fifthbuttonclick:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell setBackgroundView:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]] autorelease]]; 


} 

if(buttonClicks[indexPath.row] == YES){ 

    NSLog(@"button click is yes row is %d",indexPath.row); 
    cell.redBtn.hidden = NO; 
    cell.greenBtn.hidden = NO; 
    cell.bluebtn.hidden = NO; 
    cell.yellowbtn.hidden=NO; 
    cell.blackbtn.hidden=NO; 

} 
else { 

    cell.redBtn.hidden = YES; 
    cell.greenBtn.hidden = YES; 
    cell.bluebtn.hidden = YES; 
    cell.yellowbtn.hidden=YES; 
    cell.blackbtn.hidden=YES; 
} 

if ([[delegatObj.Favoritearray objectAtIndex:indexPath.row] isEqual:@"1"]) { 


    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected2.png"] forState:UIControlStateNormal]; 

} 
else if ([[delegatObj.Favoritearray objectAtIndex:indexPath.row] isEqual: @"2"]) { 

    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected4.png"] forState:UIControlStateNormal]; 

} 
else if ([[delegatObj.Favoritearray objectAtIndex:indexPath.row] isEqual: @"3"]) { 

    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected1.png"] forState:UIControlStateNormal]; 

} 
else if ([[delegatObj.Favoritearray objectAtIndex:indexPath.row] isEqual: @"0"]) { 

    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected.png"] forState:UIControlStateNormal]; 

} 

else if ([[delegatObj.Favoritearray objectAtIndex:indexPath.row] isEqual: @"5"]) { 

    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected3.png"] forState:UIControlStateNormal]; 

} 

else { 
    [cell.mainBtn setBackgroundImage:[UIImage imageNamed:@"starSelected.png"] forState:UIControlStateNormal]; 

} 



cell.mainBtn.buttonIndex = indexPath.row; 
cell.redBtn.buttonIndex = indexPath.row; 
cell.greenBtn.buttonIndex = indexPath.row; 
cell.bluebtn.buttonIndex = indexPath.row; 
cell.yellowbtn.buttonIndex = indexPath.row; 
cell.blackbtn.buttonIndex = indexPath.row; 


cell.cellNameLabel.text=[delegatObj.Holidaynamearray objectAtIndex:indexPath.row]; 



NSString *myString =[delegatObj.Datearray objectAtIndex:indexPath.row]; 


if ([myString length]==16) { 
    NSRange stringRange = {0, MIN([myString length],11)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 

} 

if ([myString length]==15) { 
    NSRange stringRange = {0, MIN([myString length],10)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 

} 
if ([myString length]==14) { 
    NSRange stringRange = {0, MIN([myString length],9)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 
    //[shortString release]; 

} 
if ([myString length]==13) { 
    NSRange stringRange = {0, MIN([myString length],8)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 

} 
if ([myString length]==12) { 
    NSRange stringRange = {0, MIN([myString length],7)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 


} 
if ([myString length]==11) { 
    NSRange stringRange = {0, MIN([myString length],6)}; 
    stringRange = [myString rangeOfComposedCharacterSequencesForRange:stringRange]; 

    // Now you can create the short string 
    NSString *shortString = [myString substringWithRange:stringRange]; 
    cell.cellDateLabel.text=shortString; 

} 



cell.cellDayLabel.text=[delegatObj.Dayarray objectAtIndex:indexPath.row]; 


NSString *countynamestrng=[delegatObj.Countryarray objectAtIndex:indexPath.row]; 

cell.cellcountryLabel.text=countynamestrng; 
NSLog(@"%@",countynamestrng); 

cell.c1.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png", countynamestrng]]; 
return cell; 

}

方法とカスタマイズのUITableViewCellを解放するには?

答えて

0

右の行の後に

ありがとう:はい

[cell autorelease]; 
+0

cell = [[CustomizedCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"CustomizedCell"]; 

これを行います。漏れがなくなった。 –