मुझे एक कस्टम UITableView अनुभाग शीर्षलेख को एनिमेट करने में समस्या हो रही है।
लक्ष्य ढहने योग्य वर्ग बनाना था।
जब मैं कस्टम हेडर पर टैप करता हूं तो पहली बार यह अपेक्षित के रूप में एनिमेट करता है, हालांकि हर बार जब यह मूल स्थान में डुप्लिकेट छोड़ देता है और दूसरे को एनिमेट करता है।UITableView कस्टम सेक्शन हैडर, डुप्लिकेट समस्या
छवि उदाहरण:
alt text http://img35.imageshack.us/img35/4018/screenshot2010022722565.png alt text http://img291.imageshack.us/img291/8287/screenshot2010022723035.png
मेरा कस्टम हेडर:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView* customView = [[[UIView alloc]initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)]autorelease];
customView.backgroundColor = [UIColor lightGrayColor];
UILabel * headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor darkGrayColor];
headerLabel.font = [UIFont boldSystemFontOfSize:16];
headerLabel.frame = CGRectMake(10, 7, 260.0, 44.0);
headerLabel.textAlignment = UITextAlignmentCenter;
NSDictionary *dictionary = [self.data objectAtIndex:section];
headerLabel.text = [dictionary objectForKey:@"Title"];
[customView addSubview:headerLabel];
// add button to right corner of section
UIButton* headerButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 0, 320, 44)];
headerButton.center = CGPointMake(160.0, 22.0);
headerButton.backgroundColor = [UIColor clearColor];
headerButton.tag = section;
[headerButton addTarget:self action:@selector(expandSection:) forControlEvents:UIControlEventTouchUpInside];
[customView addSubview:headerButton];
return customView;
}
मेरे एनीमेशन विधि:
- (void) expandSection:(id)sender {
if (expandedSection == [sender tag]) {
expandedSection = -1;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:[sender tag]] withRowAnimation:UITableViewRowAnimationNone];
}else if (expandedSection == -1){
expandedSection = [sender tag];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:[sender tag]] withRowAnimation:UITableViewRowAnimationNone];
}else{
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:expandedSection] withRowAnimation:UITableViewRowAnimationNone];
expandedSection = [sender tag];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:[sender tag]] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}
//[self.tableView reloadData];
}
मैं क्या चल रहा बिल्कुल यकीन नहीं है, लेकिन उदाहरण बताते हैं कि मुझे कुछ सौदा करने की ज़रूरत है। मैंने कुछ चीजों की कोशिश की है लेकिन मैं इसे समझ नहीं सकता। इस पर कोई भी मदद महान होगा!
संपादित करें: मुझे विश्वास है कि समस्या यह है कि पुनः लोड करना कस्टम दृश्य को उदाहरण के कारण बना रहा है। मैं दृश्य को जारी नहीं कर सकता क्योंकि मुझे एनीमेशन के लिए अद्यतन करने के संदर्भ के रूप में इसकी आवश्यकता है। इस पर कोई विचार है कि मैं इसे ठीक करने के लिए क्या कर सकता हूं?
धन्यवाद, यह एक संबंधित समस्या को हल करता है जहां मैं एक ही पंक्तियों को हटाने/डालने का एनिमेटेड प्रभाव उत्पन्न करना चाहता था, जहां पहले बिना 'रीलोडडाटा' को कॉल किए बिना, यह केवल हटाए गए संदेशों को एनिमेट करेगा, लेकिन आवेषण को एनिमेट नहीं करेगा। यह बहुत अजीब मुद्दा था। – Jeremy
अच्छा तरीका ... + 1 आपके लिए आदमी – Sabby