将UITableview底行滚动到顶部位置

时间:2014-04-04 18:15:49

标签: ios uitableview uiscrollview xcode5

在一个tableView中,我在section0上有4行,在section1上有3行。如果我在indexPath(1,2)处点击该行,则会出现另一行,其中包含UIPickerView。我希望tableView滚动,以便pickerView在屏幕顶部移动。为此,我实施了

[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];

但这只是向上滚动了一点,不多。

这里有什么我想念的吗?任何帮助将非常感激。提前谢谢。

1 个答案:

答案 0 :(得分:0)

嗯,那很尴尬。在这种情况下,您不需要上面的代码介于

之间
[self.tableView beginUpdates];

...

[self.tableView endUpdates];

如果有人遇到同样的问题,我会在这里留下答案。