Mur*_*gal 7 objective-c uitableview ios
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,如何在第一行的动画完成后执行第二行?
我试过这个......
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft];
{
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
[self.tableView endUpdates];
}
[self.tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)
还有这个...
[self.tableView beginUpdates];
{
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft];
}
[self.tableView endUpdates];
[self.tableView beginUpdates];
{
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
}
Run Code Online (Sandbox Code Playgroud)
......但无论哪种方式,动画都是在同一时间发生的(当动画速度很慢时,动画真的很明显).
Mur*_*gal 24
谢谢Iducool指点我另一个问题.
这有效......
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
}];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft];
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)
我似乎没有需要UITableView的beginUpdates和endUpdates.
| 归档时间: |
|
| 查看次数: |
7958 次 |
| 最近记录: |