swift – 当滚动到底部时,UITableView加载更多
发布时间:2020-12-14 05:50:09 所属栏目:百科 来源:网络整理
导读:我想在用户滚动到表格底部时加载更多数据并创建其他单元格。我正在使用JSON数据和MySql。 func dataJsonFromURL(url:String)-NSArray{ if let data = NSData(contentsOfURL: NSURL(string: url)!) { return ((try! NSJSONSerialization.JSONObjectWithData(d
我想在用户滚动到表格底部时加载更多数据并创建其他单元格。我正在使用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 } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 正则表达式 – 使用FilesMatch进行.htaccess缓存
- React Native style属性重载
- ruby-on-rails – 我可以在render.js上执行的视图中使用Cof
- 本地提供XML数据,Android端获取并解析成List集合显示
- vue-cli构建项目使用 less的方法
- 软件设计原则----单一职责原则(SRP)
- c – 奇怪的函数语法:auto(* f3)(int n) – > int(*)[n];
- Sqlite数据库中索引的使用、索引的优缺点
- cocos2d-js actiontimeline的eventFrame错误自动调用
- Dependency Property 依赖属性