0

我想以编程方式在表格视图、选择器视图中执行滚动。

程序应根据给定的起点和终点在视图中滚动。如何做到这一点。此代码用于测试 ui 应用程序。

谢谢

4

1 回答 1

1

UITableView您可以使用 以编程方式滚动 a scrollToRowAtIndexPath:atScrollPosition:animated:,例如:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:2 inSection:1];
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];

UIPickerView您使用的情况selectRow:inComponent:animated:下,例如:

[pickerView selectRow:2 inComponent:0 animated:YES];

在一个UIDatePicker你会使用setDate:animated:,例如:

[datePicker setDate:[NSDate date] animated:YES];
于 2012-04-19T13:46:33.840 回答