-2

我有一个 10 行的 UITableView。通过单击第一行,我想滚动到 UITableView 的第 5 行。

我怎样才能做到这一点?

4

2 回答 2

0

应该管用!

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath
 {
     if(indexPath.row == 0)    {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:4 inSection:0];
       [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
     }
}
于 2013-11-12T00:56:57.017 回答
0

试试这个:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    if (indexPath.row == 0) {
        [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:5 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }
}
于 2013-11-12T00:57:35.107 回答