2009-11-12 16 views
9

मेरे पास एक समूहीकृत तालिका दृश्य है जहां मैं एक विशेष पंक्ति को फिर से लोड करना चाहता हूं। जब मैं reloadRowsAtIndexPaths को कॉल करता हूं: पंक्ति तालिका दृश्य से पूरी तरह से गायब हो जाती है। क्या मुझे कुछ और करने की ज़रूरत है?क्या मैं 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

क्या आपने कभी यह हल किया है? मुझे एक ही समस्या है। – MikeyWard

उत्तर

10

अंदर

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

जैसे अपने ReloadRowsAtIndexPaths लपेटकर प्रयास करें

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

मुझे पूरी तरह से reloadRowsAtIndexPaths को हटाने में मदद मिली: और केवल [self.tableView startUpdates] छोड़ दिया; [self.tableView endUpdates]; – Krizai

+0

बस जानकारी के लिए। मैंने एक 'startUpdates'' endUpdates' ब्लॉक में कई 'reloadRowsAtIndexPaths' को लपेटने का प्रयास किया, लेकिन इसके परिणामस्वरूप' accessoryView' के साथ एक अजीब व्यवहार हुआ, जो एक संपत्ति में संग्रहीत 'UISwitch' था। और जब दस्तावेज़ों को प्रारंभ/समाप्ति पढ़ना सम्मिलन, विलोपन और चयन के लिए उपयोग किया जाता है। –

5

मैं हाल ही में iPhone SDK सीखने शुरू कर दिया और सबसे शायद मैं तुम्हें जवाब दे नहीं कर सकते ... लेकिन, नहीं है आप के साथ if (nil == cell) ब्लॉकों में कोड को बदलने के लिए

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

+1 मैं @CodeSeavers से सहमत हूं। ऐसा लगता है कि आप किसी भी सेल आवंटित नहीं कर रहे हैं। यहां तक ​​कि यदि आप 'कसरत DifficultyCell'' को कुछ आवंटित कर रहे हैं, तो आपको तालिका में अन्य कक्षों के लिए उनमें से अधिक आवंटित करने की आवश्यकता है। मैं आपको और जानने के लिए ऐप्पल की वेबसाइट पर TableViewSuite की समीक्षा करने की सलाह देता हूं। – AWrightIV

3

मेरे पास एक ही समस्या थी और स्पष्ट रूप से withRowAnimation:UITableViewRowAnimationNone को मेरे लिए हल किया गया था। क्यों नहीं कह सकता है, लेकिन अन्यथा सेल एक अच्छी एनीमेशन बनाता है और फिर चला जाता है।

3
dispatch_async(dispatch_get_main_queue(), ^{ 
     [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 
    }); 
संबंधित मुद्दे