 
 //MARK:UITableView Delegates
 extension ViewController : UITableViewDataSource ,UITableViewDelegate{
+    
+    func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        let total = scrollView.contentSize.height
+        let current = scrollView.contentOffset.y + UIScreen.main.bounds.height
+        let page = "1"    // 计算当前下拉页码
+        if loadPageDatas .contains(page) == false  && total - current  < 100{
+            loadPageDatas.append(page)
+              preLoading()
+        }
+    }
+
+    func preLoading() {
+        print("request Networking")
+    }
     
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
         return 120;


class ViewController: UIViewController {
    
    var sourceDatas = [String]()
    
    lazy var tableView: UITableView = {
        let tableView = UITableView(frame: CGRect(x: 0, y: 74, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
        tableView.backgroundColor = .white

    override func viewDidLoad() {
        navigationItem.title = "tableViewDemo"
        view.addSubview(tableView)
        sourceDatas = ["LFL","DragonLi","tableView","Do not Click item","LFL","DragonLi","tableView","Do not Click item","LFL","DragonLi","tableView","Do not Click item"]
        tableView.reloadData()
    }
    
