Clicked Header Section is scroll to top

前端 未结 1 348
孤城傲影
孤城傲影 2021-01-26 09:48

I have the following custom headerview implementation. When user clicks on headerView and it expands to show corresponding cells.

Let\'s imagine I have two sections. An

相关标签:
1条回答
  • 2021-01-26 10:21

    Since Fade takes about half a second to execute, you will see that flick. What you need to do is either giving a small delay to TableViewScroll, or just using:

    [CATransaction begin];
    [comboTableView beginUpdates];
    [CATransaction setCompletionBlock: ^{
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:section];
    
       [comboTableView scrollToRowAtIndexPath:indexPath
                              atScrollPosition:UITableViewScrollPositionTop
                                      animated:YES];
    }];
    for (int i = 0; i< ((ComboItem*)comboItemsArray[section]).allComboItems.count; i++)
        {
            NSArray* rowsToReload = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:i inSection:section], nil];
            [comboTableView reloadRowsAtIndexPaths:rowsToReload
                                       withRowAnimation:UITableViewRowAnimationFade];
        }
    [comboTableView endUpdates];
    [CATransaction commit];
    
    0 讨论(0)
提交回复
热议问题