Ios 如何用大数据填充表视图

Ios 如何用大数据填充表视图,ios,swift,uitableview,Ios,Swift,Uitableview,我试图用大量数据填充表视图。但是,我的tableview只能显示20个字符串对象。如何简单地显示其余的数据,并在用户每次滚动到末尾时更新表视图 var people = [People]() let configureSession = URLSessionConfiguration.default let session = URLSession(configuration: configure) //Setup the Api Key... let apiKey

我试图用大量数据填充表视图。但是,我的tableview只能显示20个字符串对象。如何简单地显示其余的数据,并在用户每次滚动到末尾时更新表视图

var people = [People]()
let configureSession = URLSessionConfiguration.default


    let session = URLSession(configuration: configure)

    //Setup the Api Key...
    let apiKey = "https://congress.api.sunlightfoundation.com/legislators?apikey=(//Api Key here...)"

if error != nil{
                print("ERROR: \(error?.localizedDescription)")
                return
            } else if let jsonData = data {
                do{
                    let parsedJSON = try JSONSerialization.jsonObject(with: jsonData, options: []) as! [String: AnyObject]
                    guard let results = parsedJSON["results"] as? [[String: AnyObject]] else {return}
                    for result in results{
                        let name = myClass()
name.firstName = result["first_name"] as! String
self.people.append(name)
}
                    DispatchQueue.main.async {
                        //Reload the data
                        self.table.reloadData()
                    }
                } catch let error as NSError{
                    print(error)
                }
            }
}).resume()
    }
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return people.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
        cell.textLabel?.text = people[indexPath.row] //Only displays 20... Need to display more!

    return cell!
}

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
    //Code to display the rest of the data goes here?

}

确保在
numberOfRowsInSection
方法中返回正确的值:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return myLargeData.count
}

使用提供的
myLargeData
数组,tableView中应该有30行

您可以使用table view委托的section委托中的行数来处理数组中的更多数据

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
{
    return yourarray.count
}

您的意思是大数据不明白它将显示所有[array count]简单答案,只需告诉
UITableView
要显示多少项,以及它们将如何通过
UITableViewDelegate
UITableViewDataSource
显示即可。让系统处理其余部分。将
numberofrowsinssection
的代码张贴在不相关的部分,但决不要在
willDisplayCell
中创建重复使用的单元格。受影响的单元格在
单元格
参数中传递。