UITableView load more when scrolling to bottom

前端 未结 6 444
深忆病人
深忆病人 2020-12-08 00:28

I would like to load more data and create additional cells when the user scrolls to the bottom of the table. I\'m using JSON data and MySql.

func dataJsonFro         


        
6条回答
  •  太阳男子
    2020-12-08 01:03

    you have to use this method

    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
                let lastElement = dataSource.count - 1
                if indexPath.row == lastElement {
                    // handle your logic here to get more items, add it to dataSource and reload tableview
                    }    
            }
    

提交回复
热议问题