我想在用户滚动到表格底部时加载更多数据并创建其他单元格。我正在使用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 } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。