3 回答

TA貢獻1805條經驗 獲得超9個贊
請注意,在iOS 7上,使用UIView Animation將CATransaction圍繞起來可以控制表格動畫的持續時間。
[UIView beginAnimations:@"myAnimationId" context:nil];
[UIView setAnimationDuration:10.0]; // Set duration here
[CATransaction begin];
[CATransaction setCompletionBlock:^{
? ? NSLog(@"Complete!");
}];
[myTable beginUpdates];
// my table changes
[myTable endUpdates];
[CATransaction commit];
[UIView commitAnimations];
UIView動畫的持續時間對iOS 6無效。也許在UIView級別,iOS 7表格動畫的實現方式有所不同。

TA貢獻1815條經驗 獲得超10個贊
如今,如果要執行此操作,則可以從iOS 11開始使用新功能:
- (void)performBatchUpdates:(void (^)(void))updates
completion:(void (^)(BOOL finished))completion;
在更新閉包中,放置與beginUpdates()/ endUpdates部分相同的代碼。并且在所有動畫之后執行完成。

TA貢獻1853條經驗 獲得超6個贊
剛遇到這個。方法如下:
目標C
[CATransaction begin];
[tableView beginUpdates];
[CATransaction setCompletionBlock: ^{
// Code to be executed upon completion
}];
[tableView insertRowsAtIndexPaths: indexPaths
withRowAnimation: UITableViewRowAnimationAutomatic];
[tableView endUpdates];
[CATransaction commit];
迅速
CATransaction.begin()
tableView.beginUpdates()
CATransaction.setCompletionBlock {
// Code to be executed upon completion
}
tableView.insertRowsAtIndexPaths(indexArray, withRowAnimation: .Top)
tableView.endUpdates()
CATransaction.commit()
- 3 回答
- 0 關注
- 1045 瀏覽
添加回答
舉報