iOS UITableView Scroll to bottom of section

前端 未结 5 433
鱼传尺愫
鱼传尺愫 2021-01-01 23:48

I am going to make a tableview with 2 sections inside it. I can add cells to every section programmatically and when i add, i scroll to the end of tableview using



        
5条回答
  •  醉梦人生
    2021-01-02 00:40

    You can try with this code:

    int yourSection = 2;
    int lastRow = [tableView numberOfRowsInSection:yourSection] - 1;
    [tableView scrollToRowAtIndexPath:[NSIndexPath lastRow inSection:yourSection] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    

    You get the numbers of rows in your section, then scroll to that indexPath.

提交回复
热议问题