2009-11-12 13 views
9

Belirli bir satırı yeniden yüklemek istediğim bir gruplandırılmış tablo görünümü var. ReloadRowsAtIndexPaths çağırdığımda: satır tablo görünümünden tamamen kaybolur. Yapmam gereken başka bir şey var mı?Yanlış anlama reloadRowsAtIndexPaths:

//this is the method doing the reload 
-(void)setDurationTableViewCell:(NSString *)dur { 

    self.workoutDuration = dur; 
    NSIndexPath *durPath = [NSIndexPath indexPathForRow:3 inSection:0]; 
    NSArray *paths = [NSArray arrayWithObject:durPath]; 
    [woTableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight]; 

}//end setDurationTableViewCell 


//this is the cellForRowAtIndexPath method if it has anything to do with my issue 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    UITableViewCell *cell; 

    if (indexPath.row == 0) { 

     //workout comments 
     cell = [tableView dequeueReusableCellWithIdentifier:@"workoutCommentsCell"]; 
     if (nil == cell) { 
      cell = workoutCommentsCell; 
      cell.selectionStyle = UITableViewCellStyleValue1; 
     } 

    }else if (indexPath.row == 1) { 

     //difficulty 
     cell = [tableView dequeueReusableCellWithIdentifier:@"workoutDifficultyCell"]; 
     if (nil == cell) { 
      cell = workoutDifficultyCell; 
      cell.selectionStyle = UITableViewCellStyleValue1; 
     } 
     cell.textLabel.text = [NSString stringWithFormat:@"Difficulty: %@", self.workoutDifficulty]; 

    }else if (indexPath.row == 2) { 

     //workoutDate 
     cell = [tableView dequeueReusableCellWithIdentifier:@"workoutDateCell"]; 
     if (nil == cell) { 
      cell = workoutDateCell; 
      cell.selectionStyle = UITableViewCellStyleValue1; 
     } 
     cell.textLabel.text = [NSString stringWithFormat:@"Date: %@", self.workoutDate]; 

    }else if (indexPath.row == 3) { 

     //workoutDuration 
     cell = [tableView dequeueReusableCellWithIdentifier:@"workoutTimerCell"]; 
     if (nil == cell) { 
      cell = workoutTimeCell; 
      cell.selectionStyle = UITableViewCellStyleValue1; 
     } 
     cell.textLabel.text = [NSString stringWithFormat:@"Duration: %@", self.workoutDuration]; 

    }//end else-if 


    return cell; 

}//end cellForRowAtIndexPath 
+0

Bunu hiç çözdünüz mü? Aynı sorunu yaşıyorum. – MikeyWard

cevap

10

[self.tableView beginUpdates]; 
[self.tableView endUpdates]; 

ör içerdeki ReloadRowsAtIndexPaths kaydırma deneyin

[self.tableView beginUpdates]; 
[woTableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationRight]; 
[self.tableView endUpdates] 
+0

Bana yardımcı olan şey tamamen reloadRowsAtIndexPaths öğesini kaldırır: ve sadece [self.tableView beginUpdates]; [self.tableView endUpdates]; – Krizai

+0

Sadece bilgi için. Birkaç 'relUpRowsAtIndexPaths'ı bir' beginUpdates'' endUpdates 'bloğuna sarmayı denedim, ancak bu bir özellik içinde saklanan' UISwitch' olan 'accessoryView' ile garip bir davranış ortaya çıkardı. Ve belgelerini okurken başlat/endUpdates, ekleme, silme ve seçim için kullanılır. –

5

Geçenlerde iPhone SDK öğrenmeye başladı ve büyük olasılıkla i ile if (nil == cell) bloklar halinde kodunu değiştirmek zorunda değilim, size cevap vermek ... Ama veremeyiz

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 
reuseIdentifier:@"workoutTimerCell"] autorelease]; 
+1

+1 @CodeSeavers ile aynı fikirdeyim. Herhangi bir hücre ayırmıyor gibi görünüyor. 'WorkoutDifficultyCell' için bir şey ayırıyor olsanız bile, daha fazlasını masadaki diğer hücreler için ayırmanız gerekir. Daha fazla bilgi edinmek için Apple'ın web sitesinde TableViewSuite'ı gözden geçirmenizi öneririz. – AWrightIV

3

Aynı sorunu yaşadım ve görünüşte withRowAnimation: ayarını UITableViewRowAnimationNone olarak ayarlayarak benim için çözdüm. Neden olduğunu söyleyemem, ama aksi halde hücre güzel bir animasyon yapar ve sonra gider.

3
dispatch_async(dispatch_get_main_queue(), ^{ 
     [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 
    });