Parse.com query.limit 在 PFCollectionView 中不起作用
Parse.com query.limit doesn't work in PFCollectionView
首先,感谢您的帮助。我正在编写一个使用 Swift 开发的 iOs 应用程序,我正在使用 Parse.com。在名为 liste_joueurs 的 class 中,大约有 15 行。但是,我只想检索前四个结果。
我阅读了文档并找到了 query.limit 属性。不幸的是,当我 运行 我的代码时,在我的集合中,我的 class 中的所有行都出现了(query.limit 不起作用)。
有人有解决办法吗?
override func queryForCollection() -> PFQuery {
let query = PFQuery(className: "liste_joueurs")
query.limit = 4 // Useless
query.orderByAscending("nom")
return query
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFCollectionViewCell? {
println(object["nom"]?.count)
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("statsCell", forIndexPath: indexPath) as! StatsViewCell
// CELL'S TREATMENT
return cell
}
PS:当我使用这样的约束时:
query.whereKey("nom", hasPrefix: "ba")
查询 "is filtered" 并且只有以 "ba" 开头的行出现在我的集合中...
只有这段代码我可以说如果你使用 PFQueryCollectionViewController
而不是确保 paginationEnabled = false
,否则它将被忽略。如果您使用 objectsPerPage
那么它将覆盖 limit
首先,感谢您的帮助。我正在编写一个使用 Swift 开发的 iOs 应用程序,我正在使用 Parse.com。在名为 liste_joueurs 的 class 中,大约有 15 行。但是,我只想检索前四个结果。
我阅读了文档并找到了 query.limit 属性。不幸的是,当我 运行 我的代码时,在我的集合中,我的 class 中的所有行都出现了(query.limit 不起作用)。
有人有解决办法吗?
override func queryForCollection() -> PFQuery {
let query = PFQuery(className: "liste_joueurs")
query.limit = 4 // Useless
query.orderByAscending("nom")
return query
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFCollectionViewCell? {
println(object["nom"]?.count)
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("statsCell", forIndexPath: indexPath) as! StatsViewCell
// CELL'S TREATMENT
return cell
}
PS:当我使用这样的约束时:
query.whereKey("nom", hasPrefix: "ba")
查询 "is filtered" 并且只有以 "ba" 开头的行出现在我的集合中...
只有这段代码我可以说如果你使用 PFQueryCollectionViewController
而不是确保 paginationEnabled = false
,否则它将被忽略。如果您使用 objectsPerPage
那么它将覆盖 limit