Xin chào các bạn. tôi có một vấn đề với hoạt hình xóa và chèn trên một UITableView. Thực tế ist, rằng tôi có cellheights khác nhau, một số 44,0 một số 135,0 bây giờ. tôi có uitableviewstylegrouped với các phần khác nhau. hàng đầu tiên của mỗi phần là một hàng nhóm. khi nhấp vào tôi xóa tất cả các hàng của phần này ngoại trừ hàng nhóm. nhưng hoạt ảnh đó trông kỳ lạ, khi hoạt ảnh (UITableViewRowAnimationTop) ô chiều cao 135px. tôi đã cố gắng để thiết lập self.tableview.cellheight đến 135 và nhận xét ra tableView: cellHeightForIndexPath-Method. Và hoạt hình hoạt động tốt. Hoặc tôi thiết lập tất cả các cellheight đến 135 trong tableView: cellHeightForIndexPath-Method.Sự cố với RowAnimation
Dường như quy trình hoạt ảnh kiểm tra độ cao của hàng đầu tiên trong các phần, mất chiều cao của ô cho tất cả các ô sau đây hoạt ảnh.
Ai đó là một ý tưởng?
- (void) showhideGroup:(int)group
{
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
MCGroup *handleGroup = [groups objectAtIndex:group];
NSMutableArray *groupRows = [visibleGroupData objectForKey:handleGroup.title];
[self.tableView beginUpdates];
if (!handleGroup.hidden) {
int row = 0;
for(MobileFieldMapping *field in groupRows)
{
if (![field.datatype matchesInsensitive:GROUPING_CELL])
{
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:group];
[indexPaths addObject:path];
}
row++;
}
row = 0;
for(NSIndexPath *index in indexPaths)
{
[groupRows removeObjectAtIndex:index.row-row];
row++;
}
[self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop];
handleGroup.hidden=YES;
}
else
{
NSMutableArray *allGroupRows = [groupData objectForKey:handleGroup.title];
int row = 0;
for (MobileFieldMapping *field in allGroupRows)
{
if (![groupRows containsObject:field])
{
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:group];
[indexPaths addObject:path];
[groupRows insertObject:field atIndex:row];
}
row++;
}
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop];
handleGroup.hidden=NO;
}
[self.tableView endUpdates];
[indexPaths release];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
if ([cell isKindOfClass:[FormCell class]])
{
return [(FormCell*)cell height];
}
return 44.0;
}
bạn nên đăng bảng xem mã nguồn của đại biểu. – karim
ok không ai có ý tưởng ... có vẻ như vậy – kaelum
Tôi đã làm việc này, vì vậy tôi nghĩ rằng đó là một lỗi trong mã của bạn. Bạn cần phải đăng các mã ĐẦY ĐỦ, hoặc (tốt hơn) làm cho một ví dụ nhỏ hơn của vấn đề. Ngoài ra, bạn cần phải cụ thể hơn trong việc mô tả chính xác cách nó "trông kỳ lạ" - không ai có thể giúp bạn với sự mơ hồ như vậy. – Adam