How to make dynamically adding of rows when user reached to the last row of the UITableView?

后端 未结 4 742
夕颜
夕颜 2021-02-02 04:19

I have a UITableview which shows 10 rows currently which is fixed static. Now I want to add a feature into it. I want to add a more 10 rows to the table when user r

4条回答
  •  太阳男子
    2021-02-02 04:54

    uitableview is derived from uiscrollview. To achieve your objective, you need to implement scrollViewDidEndDecelerating:

     - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
        if (endScrolling >= scrollView.contentSize.height) 
        {
          // your code goes here
        }
    }
    

    This will detect a "bouncing effect" like shifting up the visible rows to indicate that one would like to see more.

提交回复
热议问题