gpt4 book ai didi

iphone - 如何知道 UITableView 动画何时完成?

转载 作者:行者123 更新时间:2023-12-03 18:28:00 24 4
gpt4 key购买 nike

我想做一系列的事情来响应某些 UITableView 动画的结束。例如,我希望 TableView 单元格在通过scrollToRowAtIndexPath滚动到后突出显示(通过selectRowAtIndexPath)。

如何做到这一点?

最佳答案

基本模板:

[UIView animateWithDuration:0.2 animations:^{
//do some animations, call them with animated:NO
} completion:^(BOOL finished){
//Do something after animations finished
}];

示例:滚动到第100行。完成后,获取该行的单元格,并将tag=1的单元格内容 View 设置为firstResponder:

[UIView animateWithDuration:0.2 animations:^{
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:100 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
} completion:^(BOOL finished){
//Do something after scrollToRowAtIndexPath finished, e.g.:
UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:100 inSection:0]];
[[nextCell.contentView viewWithTag:1] becomeFirstResponder];
}];

关于iphone - 如何知道 UITableView 动画何时完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1339525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com