swift – 当滚动到底部时,UITableView加载更多

swift – 当滚动到底部时,UITableView加载更多,第1张

概述我想在用户滚动到表格底部加载更多数据并创建其他单元格。我正在使用JSON数据和MySql。 func dataJsonFromURL(url:String)->NSArray{ if let data = NSData(contentsOfURL: NSURL(string: url)!) { return ((try! NSJSONSerialization.JSON 我想在用户滚动到表格底部时加载更多数据并创建其他单元格。我正在使用JsON数据和MysqL。
func dataJsonFromURL(url:String)->NSArray{    if let data = NSData(contentsOfURL: NSURL(string: url)!) {        return ((try! NSJsONSerialization.JsONObjectWithData(data,options: [])) as! NSArray)    }    else{        return data    }}func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell{    let cell = tableVIEw.dequeueReusableCellWithIDentifIEr("NCell",forIndexPath: indexPath) as! tableVIEwCell22    cell.backgroundcolor = UIcolor .clearcolor()    let mindata = (data[indexPath.row] as! NSDictionary)}
你必须使用这种方法
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                }            }
总结

以上是内存溢出为你收集整理的swift – 当滚动到底部时,UITableView加载更多全部内容,希望文章能够帮你解决swift – 当滚动到底部时,UITableView加载更多所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1052188.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存