UITableView move to cell

前端 未结 3 1254
小鲜肉
小鲜肉 2020-12-09 01:02

I want to make next:

I have an UITableView that have to dispaly words (A-Z).

Currently when view did load I have one cell that displayed (and this is correct

相关标签:
3条回答
  • 2020-12-09 01:32

    You are right to identify the scrollToRowAtIndexPath method. So all you need to do is create a fresh IndexPath with the row you wish to move to, e.g., row index = 10:

    [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:10 inSection:indexPath.section] 
                 atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
    
    0 讨论(0)
  • 2020-12-09 01:37

    One can identify the row(in the eg. below it is forRow) that needs to be made visible and reload the row. Upon the completion of that one can scroll to that row.

    let moveToIndexPath = NSIndexPath(forRow: forRow, inSection: 0)
    self.tableView.reloadRowsAtIndexPaths([moveToIndexPath], withRowAnimation: .None)
    self.tableView.scrollToRowAtIndexPath(moveToIndexPath, atScrollPosition: atScrollPosition, animated: true)
    
    0 讨论(0)
  • 2020-12-09 01:41
    //For iOS 7 
            [self.TableView reloadData];
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:1];
            [TableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    
    0 讨论(0)
提交回复
热议问题