Приложение iPhone падает после выполнения метода cellForRowAtIndexPath tableView - PullRequest
0 голосов
/ 21 февраля 2011

Приложение аварийно завершает работу после выполнения метода cellForRowAtIndexPath tableView

. Оно входит в:

UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]

и вылетает.

В консоли не отображается ошибка.Он показывает EXC_BAD_EXCESS в строке состояния XCode.

Что может быть не так?

РЕДАКТИРОВАТЬ 1:

ЭтоВесь код в методе cellForRowAtIndexPath моего tableView:

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

static NSString *CellIdentifier = @"Cell";
static NSString *newCellIdentifier = @"NewCell";

UITableViewCell *cell = nil;
NSUInteger row = [indexPath row];
NSUInteger count;
if (searching==YES) {
    count = [searchCellTextArray count];
}else {
    count = [cellTextArray count];
} 

if(row==count)
      {

    cell = [tableView dequeueReusableCellWithIdentifier:newCellIdentifier];
    if (cell == nil) 
               {
        cell = [[[UITableViewCell alloc] 
                 initWithStyle:UITableViewCellStyleDefault 
                 reuseIdentifier:newCellIdentifier] autorelease];
    }
    cell.textLabel.text = @"Load more items...";


    cell.textLabel.textColor = [UIColor blueColor];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:14];

}
else 
      {
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
              {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }


    UIImage *cellImage = [[UIImage alloc] init];
    NSString *imgName;

    //Searching


    if(searching==YES && [searchCellTextArray count] != 0) 
               {

        NSString *decodedImageName = [NSString stringWithUTF8String:[[[showSearchImageArray objectAtIndex:indexPath.row]valueForKey:@"image"] cStringUsingEncoding:[NSString defaultCStringEncoding]]];
        imgName = decodedImageName;

        cell.textLabel.textColor = [UIColor redColor];
        cell.textLabel.text=[searchCellTextArray objectAtIndex:indexPath.row];

        cell.detailTextLabel.font= [UIFont boldSystemFontOfSize:18];
        cell.detailTextLabel.textColor = [UIColor blackColor];
        cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.detailTextLabel.numberOfLines= [lableNameArray count]+2;
        cell.detailTextLabel.text = [searchDetailTextArray objectAtIndex:indexPath.row];
    }
    else
              { //searching 

        NSString *decodedImageName = [NSString stringWithUTF8String:[[[showImageArray objectAtIndex:indexPath.row] valueForKey:@"image"] cStringUsingEncoding:[NSString defaultCStringEncoding]]];

        imgName = decodedImageName;


        cell.textLabel.textColor= [UIColor redColor];
        cell.textLabel.text = [cellTextArray objectAtIndex:indexPath.row];



        cell.detailTextLabel.font= [UIFont boldSystemFontOfSize:18];
        cell.detailTextLabel.textColor = [UIColor blackColor];
        cell.detailTextLabel.numberOfLines= [lableNameArray count]+2;
        cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.detailTextLabel.text = [detailTextArray objectAtIndex:indexPath.row];

    }

    if (imgName !=(NSString*)[NSNull null] && ![imgName isEqualToString:@""] && ![imgName isEqualToString:@"X"]) 
              {
        NSLog(@" Image Name : %@",imgName);

        NSString *documentsDirectory = [self getImagePath];
        NSError *error1;
        NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:&error1];
        if (files == nil) 
                        {
            NSLog(@"Error reading contents of documents directory: %@", [error1 localizedDescription]);
        }


        for (NSString *file in files) 
                        {
            NSLog(@"Loop Entered");
            if([file isEqualToString:[NSString stringWithFormat:@"%@_thumb.png",imgName]])
                  {
                NSLog(@"Image: %@ %@",file,imgName);
                NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:file];

                cellImage = [UIImage imageWithContentsOfFile:fullPath];
                NSLog(@"Full Path: %@",fullPath);

            }

        }

        cell.imageView.image = cellImage;
    }
              else 
              {
        cell.imageView.image = [UIImage imageNamed:@"GlossaryGhostImg1.png"];
    }

}
NSLog(@"Cell For Row At Index Path Done");
return cell;
}

Есть ли здесь утечки памяти, и я перевыпустил какие-либо объекты?

Ответы [ 2 ]

1 голос
/ 21 февраля 2011

Может быть много вещей: вы возвращаете мусорную ячейку.Вы выпустили свою камеру слишком много раз.Вы автоматически выпускали какой-то компонент своей ячейки слишком много раз.Похоже, проблема управления памятью, внимательно проверьте ваши сохранения / релизы.И опубликуйте свой код cellForRowAtIndexPath.

0 голосов
/ 22 февраля 2011

Попробуйте добавить переменную окружения NSZombie. Затем проверьте свое приложение. Может быть, вы найдете основную причину аварии.

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