0

我正在尝试创建一个 UITableView,它有一个选择栏,可以滚动到用户选择的任何行(请不要问为什么,我只需要这样做)。这与 UITableView 具有的典型选择栏不同,因为那里没有动画。我所做的是将 Interface Builder 中的 TableView 添加到我的主视图中,并且我还在我的主视图中添加了一个 imageView。我需要它与 UIPickerView 中的选择栏类似地工作,除了在这种情况下它是移动的选择栏。我认为此代码将驻留在内部:

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
    _imageView.frame = rect;

}

谁能向我解释我将如何编码从一个单元格到另一个单元格的选择栏动画?

提前感谢所有回复的人

4

1 回答 1

2

假设您当前拥有的代码有效:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [UIView animateWithDuration:.3 animations:^{
        CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
        _imageView.frame = rect;
    }];
}

还有+animateWithDuration:animations:completion:+animateWithDuration:delay:options:animations:completion:

于 2013-06-05T19:23:06.923 回答