अगर मैं एक खंड की पहली सेल के लिए reloadRowsAtIndexPaths कहते हैं, पिछले अनुभाग के साथ खाली और नहीं खाली ऊपर एक, मैं एक अजीब एनीमेशन गड़बड़ मिल (भले ही मैं "UITableViewRowAnimationNone" निर्दिष्ट) जहां पुनः लोड सेल ऊपर अनुभाग से नीचे स्लाइड ..UITableView reloadRowsAtIndexPaths चित्रमय गड़बड़
मैं जितना संभव हो उतना उदाहरण को आसान बनाने की कोशिश की:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0)
return 1;
else if (section == 1)
return 0;
else if (section == 2)
return 3;
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.textLabel.text = @"Text";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *editedCell = [[NSArray alloc] initWithObjects:indexPath, nil];
//[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:editedCell withRowAnimation:UITableViewRowAnimationNone];
//[self.tableView endUpdates];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Section";
}
वास्तव में आप पिछले विधि बाहर टिप्पणी कर सकते हैं, लेकिन यह समस्या का एक बेहतर समझ देता है।
एक महान समाधान है कि, वैसे भी, से अजीब व्यवहार है: इसके अलावा कोड स्पष्ट करने और कोड दोहराव से बचने के लिए एक अलग विधि (ताकि हम इसे विभिन्न स्थानों से कॉल करने के लिए सक्षम हो जाएगा) के लिए सेल सेटअप स्थानांतरित करने देता है reloadRowsAtIndex एक बग पाता है, या मैं बस इसे गलत तरीके से उपयोग कर रहा था? – Fr4ncis
@ Fr4ncis, मुझे यकीन नहीं है। कक्ष तालिका दृश्य को फिर से लोड करने के लिए उन्हें दृश्य पदानुक्रम से जोड़ने/निकालने की आवश्यकता हो सकती है, इसके कुछ सबव्यूव्स या कुछ और पुनर्निर्माण करना पड़ता है - यह इस बात पर निर्भर करता है कि इन सभी परिवर्तनों को आंतरिक रूप से लागू किया गया है – Vladimir
धन्यवाद, आपका समाधान एक अच्छी तरह से संरचित है। – jalopezsuarez