簡體   English   中英

UITableView beginUpdates / endUpdates回調

[英]UITableView beginUpdates/endUpdates callback

我正在使用beginUpdates / endUpdates塊對tableView進行更改。 在整個過程中,我需要更新一個陰影,以便它反映tableView的當前組成。

我嘗試為tableView的contentSize設置KVO,但是一旦動畫完成,它只在endUpdatesendUpdates 我想要的是每次contentSize改變時調用它(即使只是一個像素)。 有沒有辦法實現這個目標?

那這個呢?

[CATransaction begin];

[CATransaction setCompletionBlock:^{
    // animation has finished
}];

[tableView beginUpdates];
// do some work
[tableView endUpdates];

[CATransaction commit];

魯道夫的方法對我來說並不像預期的那樣順利。 在我的情況下,我使用這個在UITableView上選擇了一行,而Rudolf的方法導致表格進行兩次動畫並稍微凍結:beginUpdates / endUpdates中的動畫,一點點凍結和完成塊上的動畫。

 [tableView selectRowAtIndexPath:indexPath
                        animated:YES
                  scrollPosition:scrollPosition];

這激發了我創建這個代碼......這無縫地工作:

[UIView animateWithDuration:0.0 animations:^{
    [tableView beginUpdates];
    // do something to the table
    [tableView endUpdates];
} completion:^(BOOL finished) {
    // Code to run when table updates are complete.
}];

很抱歉,我認為你不能這樣做。 在調用beginUpdates之后對表進行更改時,更改將在endUpdates之后動畫為單個動畫。 在這些動畫期間沒有動畫回調。 我沒有試過這個,所以不知道它是否適用於此但你可以嘗試嵌套beginUpdatesendUpdates並在每次endUpdates后更新你的陰影。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM