我想创建一个"UiTableView",它可以动态向下或向上移动单元格,并将下一个单元格从数组添加到表视图中。
请给我举个好例子。
感谢Neha
到此为止:
- (IBAction)clickAction:(id)sender
{
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
[tableView reloadData];
}
或:
// (change n to whatever you like)
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:n inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
如果你需要更复杂的东西,请告诉我们。
在这个代码段中,即使还没有加载行,您也可以滚动并选择行表。
- (void)viewDidAppear:(BOOL)animated
{
NSIndexPath *index = [NSIndexPath indexPathForRow:idx inSection:0];
[_table selectRowAtIndexPath:index animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
}