2014-10-29 4 views
0

Я использую tableview в iOS. Я получаю 10 элементов в массиве, и после того, как я последний элемент на таблице, я получаю более 10 элементов. Его работа прекрасна, но некоторые ячейки перекрываются и черные в цвете. Наложение перекрытий становится нормальным после нескольких секунд, но черный цвет остается постоянным. Я новичок в iOS. Пожалуйста помоги.Ячейка стала черной из TableView в iOS

- (void)getNewMailFromBottom 
{ 
    if (!isFinished && !isSideMenu && !searching) { 
     NSInteger resultsSize = [foldersDataArray count]; 
     NSInteger count=0; 
     NSMutableArray *tempMailArray = (NSMutableArray *)[NSArray arrayWithArray:(NSArray *)[dataBase getFolderMails:[mailBoxAccountId integerValue]:currentFolderLocalId:[foldersDataArray count]:10]]; 
     if ([tempMailArray count]==0 &&[appDelegate internetConnection] && [Globals getAuthenticationTicket] && ![[Globals getAuthenticationTicket] isEqualToString:@""] && ([[NSUserDefaults standardUserDefaults]boolForKey:@"ALL_MAILS"] || [[NSUserDefaults standardUserDefaults]boolForKey:@"DEFAULT_MAILS"]) && currentFolderLocalId !=appDelegate.draftLocalId && currentFolderLocalId != appDelegate.localOutboxLocalId) { 
      [self getAllFolderDataDetail :currentFolderId:YES]; 
     } else { 
      for (NSDictionary *dict in tempMailArray) { 
       if (![foldersDataArray containsObject:dict]) { 
        [foldersDataArray addObject:[dict objectForKey:@"mailDetail"]]; 
        count++; 
       } 
      } 
      NSMutableArray *arrayWithIndexPaths = [NSMutableArray array]; 
      for (NSInteger i = resultsSize; i < resultsSize + count; i++) 
       [arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; 
      [myTableView insertRowsAtIndexPaths:arrayWithIndexPaths withRowAnimation:UITableViewRowAnimationFade]; 
      [pullToRefreshManager tableViewReloadFinished]; 
     } 
    } 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *simpleTableIdentifier = @"SimpleTableCell"; 

    SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
    if (cell == nil) { 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil]; 
     cell =[nib objectAtIndex:1]; 
     cell.selectionStyle=UITableViewCellAccessoryNone; 



    NSInteger sectionsAmount = [tableView numberOfSections]; 
     NSInteger rowsAmount = [tableView numberOfRowsInSection:[indexPath section]]; 

    if ([indexPath section] == sectionsAmount - 1 && [indexPath row] == rowsAmount-1) { 
     NSLog(@"hello"); 

     [refreshBottomConnection cancel]; 
     [self getNewMailFromBottom]; 
     [pullToRefreshManager setPullToRefreshViewVisible:NO]; } 

    return cell; 
} 
+0

разместить свой код. – Rushabh

+0

i m проводка код обязательно проверьте. –

+0

Ваша высота ячейки динамична? –

ответ

2
{ 
     double delayInSeconds = 0.30; 
     dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 
     dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 

     [refreshBottomConnection cancel]; 
     [self getNewMailFromBottom]; 
     // [pullToRefreshManager setPullToRefreshViewVisible:NO]; 

    }); 
0

Использование многоразовой ячейка таблицы и сделать редактирование на UITableView с помощью

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 

и добавить условие UITableViewCellEditingStyleInsert:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSUInteger row = [indexPath row]; 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     //Now you needn't 
    }else if(editingStyle == UITableViewCellEditingStyleInsert){ 
     NSArray *insertIndexPaths = [NSArray arrayWithObjects:indexPath,nil]; 
     [self.list insertObject:@"new Cell" atIndex:row];//The list is the cell data source array 
     [tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationMiddle]; 
    } 
} 

Как и редактирование вида клеток в этой функции:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
+0

нет нет нет 21,31,41 ... cell становится черный –

0

Проблема с кодом. Пожалуйста, проверьте код ниже.

if (cell == nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil]; 
    cell =[nib objectAtIndex:1]; 
    cell.selectionStyle=UITableViewCellAccessoryNone; 
} 

Вы отсутствующий этот последний кронштейн ...

+0

нерабочий .... –

Смежные вопросы