in my codes, i use a array 'shouldExpandSection[]' to control the section rows show/hide, as below code:- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return shouldExpandSection[section] ? rowCountOfSection[section] : 0;
}
in order to add animation effects, i create a switch show/hide action ,as below code:- (void)sectionButtonClicked:(UIButton *)sender
{
int section = sender.tag;
shouldExpandSection[section] = !shouldExpandSection[section];
[tv reloadData];
NSMutableArray *_indexPaths = [[NSMutableArray alloc] init];
for (int i=0; i< rowCountOfSection[section]; i++) {
NSUInteger _path[2] = {section,i};
NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:_path length:2];
[_indexPaths addObject:_indexPath];
[_indexPath release];
} if (shouldExpandSection[section])
{
[tv beginUpdates];
[tv reloadRowsAtIndexPaths:_indexPaths withRowAnimation:UITableViewRowAnimationFade];
[_indexPaths release];
[tv endUpdates];
}
}i use that method 'reloadRowsAtIndexPaths withRowAnimation' to bring about the Fade Animation , And seems it works well. but i have a problem, how to hide the TableView cell belong the section with animation, not insert/delete. can i enlist your help? tks a lot.
{
return shouldExpandSection[section] ? rowCountOfSection[section] : 0;
}
in order to add animation effects, i create a switch show/hide action ,as below code:
{
int section = sender.tag;
shouldExpandSection[section] = !shouldExpandSection[section];
[tv reloadData];
NSMutableArray *_indexPaths = [[NSMutableArray alloc] init];
for (int i=0; i< rowCountOfSection[section]; i++) {
NSUInteger _path[2] = {section,i};
NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:_path length:2];
[_indexPaths addObject:_indexPath];
[_indexPath release];
} if (shouldExpandSection[section])
{
[tv beginUpdates];
[tv reloadRowsAtIndexPaths:_indexPaths withRowAnimation:UITableViewRowAnimationFade];
[_indexPaths release];
[tv endUpdates];
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货