Tôi gặp sự cố khi tạo hoạt ảnh cho tiêu đề phần UITableView tùy chỉnh.
Mục tiêu là tạo các phần có thể thu gọn.
Khi tôi nhấn vào tiêu đề tùy chỉnh lần đầu tiên nó hoạt ảnh như mong đợi, tuy nhiên mỗi lần sau đó nó để lại một bản sao ở vị trí ban đầu và hoạt ảnh khác.Tiêu đề phần tùy chỉnh UITableView, vấn đề trùng lặp
Hình ảnh Ví dụ:
alt text http://img35.imageshack.us/img35/4018/screenshot2010022722565.png alt text http://img291.imageshack.us/img291/8287/screenshot2010022723035.png
Tuỳ chỉnh Tiêu đề của tôi:
- (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;
}
My Animation Phương pháp:
- (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];
}
Tôi không chắc chắn chính xác whats going on, nhưng các trường hợp cho thấy rằng tôi cần phải giải quyết một cái gì đó. Tôi đã thử một vài điều nhưng tôi không thể hiểu được điều này. Bất cứ ai giúp đỡ về điều này sẽ là tuyệt vời!
Chỉnh sửa: Tôi tin rằng vấn đề là việc tải lại Mục đang gây ra chế độ xem tùy chỉnh. Tôi không thể phát hành chế độ xem vì tôi cần nó làm tài liệu tham khảo để cập nhật cho hoạt ảnh. Bất kỳ ý tưởng về những gì tôi có thể làm để sửa lỗi này?
Cảm ơn bạn đã khắc phục sự cố liên quan nơi tôi muốn tạo hiệu ứng động khi xóa/chèn các hàng giống nhau, trong đó, trước tiên không gọi 'reloadData', nó sẽ chỉ tạo hiệu ứng xóa, nhưng không tạo hiệu ứng chèn. Vấn đề rất lạ. – Jeremy
Cách tốt ... + 1 cho bạn người đàn ông – Sabby