我在UITableView中有一个部分,一旦我点击它4个动画单元格下拉,但是,问题是当它们下拉时它们经过视图(屏幕),除非你看不见它们向下滚动。我如何制作它,以便一旦单击该部分,它会向上推动整个视图,显示下拉菜单中的所有单元格?这是我的代码:
- (void) sectionOpened : (NSInteger) section{
SectionInfo *array = [self.sectionInfoArray objectAtIndex:section];
array.open = YES;
NSInteger count = [array.category.list count];
NSMutableArray *indexPathToInsert = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i<count;i++)
{
[indexPathToInsert addObject:[NSIndexPath indexPathForRow:i inSection:section]];
}
NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init];
NSInteger previousOpenIndex = self.openSectionIndex;
if (previousOpenIndex != NSNotFound)
{
SectionInfo *sectionArray = [self.sectionInfoArray objectAtIndex:previousOpenIndex];
sectionArray.open = NO;
NSInteger counts = [sectionArray.category.list count];
[sectionArray.sectionView toggleButtonPressed:FALSE];
for (NSInteger i = 0; i<counts; i++)
{
[indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:previousOpenIndex]];
}
}
UITableViewRowAnimation insertAnimation;
UITableViewRowAnimation deleteAnimation;
if (previousOpenIndex == NSNotFound || section < previousOpenIndex)
{
insertAnimation = UITableViewRowAnimationTop;
deleteAnimation = UITableViewRowAnimationBottom;
}
else
{
insertAnimation = UITableViewRowAnimationBottom;
deleteAnimation = UITableViewRowAnimationTop;
}
[atableView beginUpdates];
[atableView insertRowsAtIndexPaths:indexPathToInsert withRowAnimation:UITableViewRowAnimationTop];
[atableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation];
[atableView endUpdates];
self.openSectionIndex = section;
}
任何想法?
答案 0 :(得分:0)
您是否尝试过使用此tableView方法?
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
所以你可以试试。
[atableView scrollToRowAtIndexPath:indexPathToInsert atScrollPosition: UITableViewScrollPositionTop animated:YES];