2017-07-16 5 views
0

私は次のカスタムヘッダービューの実装を持っています。ユーザーがheaderViewをクリックすると、展開されて対応するセルが表示されます。クリックされたヘッダーセクションは上にスクロールされます

私は2つのセクションがあるとしましょう。最初のセクションは展開され、2番目のセクションは折りたたまれます。 2番目のセクションをクリックすると、このセクションが上部にスクロールされます。

+0

選択したセクションがテーブルの一番上になるまでスクロールする必要がありますか? –

+0

'[comboTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop アニメーション:はい];それをしていますか? – hotspring

+0

その方法は何かをやっている?私はスクロールを少なくとも少し意味する? –

答えて

0

フェードの実行には約0.5秒かかりますので、そのフリックが表示されます。あなたがする必要があるのは、TableViewScrollにわずかな遅延を与えるか、単に次のように使用することです:

[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]; 
関連する問題