- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
美好的一天!我在我的 swift 项目中使用 Parse,现在我的问题是加载查询或对象并将其保存到 localDataStore,我尝试了这种方法
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as CustomPFTableViewCell!
if cell == nil {
cell = CustomPFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
}
// Extract values from the PFObject to display in the table cell
if let placeName = object?["placeName"] as? String {
cell.cellName.text = placeName
}
if let station = object?["station"] as? String {
cell.cellDetail.text = station
}
if let placeImg = object?["placeImg"] as? String {
let decodedData = NSData(base64EncodedString: placeImg, options: NSDataBase64DecodingOptions(rawValue: 0))
// var decodedimage = UIImage(data: decodedData!)
var finImage = UIImage(data: decodedData!)
cell.cellBgImg.image = finImage
}
PFObject.pinAllInBackground(self.objects, block: { (succeeded, error) -> Void in
if (error == nil) {
}else {
println(error!.userInfo)
}
})
return cell
}
现在在我的 queryForTable 方法中我有这个
override func queryForTable() -> PFQuery {
// Start the query object
var query = PFQuery(className: "Places")
// Add a where clause if there is a search criteria
if searchBar.text != "" {
query.whereKey("filterKeyword", containsString: searchBar.text.lowercaseString)
}
// Order the results
query.orderByAscending("placeName")
var cReturn = PFQuery()
if (IJReachability.isConnectedToNetwork()) {
cReturn = query
} else {
cReturn = query.fromLocalDatastore()
}
return cReturn
}
如您所见,我正在使用 Reachability
检查设备是否已连接到互联网。如果没有,查询将返回 query.fromLocalDataStore
如果设备已连接,它将返回正常的 query
获取最新数据。
现在,我的问题是当我关闭互联网来测试它时,它给了我一个错误 'Method requires Pinning enabled.'
我已经在tableView
中做过了方法
PFObject.pinAllInBackground(self.objects, block: { (succeeded, error) -> Void in
if (error == nil) {
}else {
println(error!.userInfo)
}
})
你认为我做错了什么?谢谢!
最佳答案
我认为您应该将固定对象的方法放在 objectsDidLoad()
方法中,而不是放在 cellForRowAtindexPath()
方法中。
关于Swift - 加载 LocalDataStore 时解析 PFQueryTableViewController 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31318724/
简单:我想要用屏幕的宽度和高度计算图片的大小以保持宽高比,类似于9gag应用程序。 如何在PFQueryTableViewController中制作单元格的动态高度,在我的单元格中,我在自定义单元格中
我想使用 PFQueryTableViewController 显示来自 Parse.com 的联系人列表,但是我可以显示来自 Parse.com 的数据。现在,我在 Parse.com 的其他列中添
所以我正在使用 Swift 2 和 Xcode 7 创建一个应用程序,并使用 Parse 作为我的后端服务。我有两个 View Controller ,一个用于显示 PFObject 列表的 PFQu
我有一个 pfquery tableview Controller ,该 Controller 在类中包含许多 pfobject,这些对象正在加载到我的 pfquerytableviewcontrol
我正在尝试对 PFQuery tableview Controller 设置限制,但它不起作用。我正在尝试使其加载 1 个单元格,然后在分页后加载另一个单元格,然后加载另一个单元格。 这是我的代码。
我想要一个包含两个部分的 PFQueryTableViewController: 第 1 部分:显示查询的 PFObjects(地址簿中正在使用该应用程序的联系人) 第 2 部分:显示数组的对象(地址
我正在将来自 User 类的用户数据从 Parse 加载到 PFQueryTableViewController 中。用户类代表来自 Facebook 的数据。现在,我不想将数据加载到当前登录用户的
我有一个 PFQueryTableViewController,我想向 tableview 添加部分,我这样尝试: - (PFQuery *)queryForTable { PFQuery *qu
我的应用程序中有一个 PFQueryTableViewController。如果它是 Controller 的 Root View ,那很好。但是,如果我将它推到另一个 View ,就会有一条奇怪的线
我有一个关于如何拦截 PFQueryTableViewController 上的错误消息的问题。基本上,我想重写 PFQueryTableViewController 中的一个方法,以便在执行查询时出
在将所有内容移至 Heroku 之后,我正在使用开源 Parse 服务器更新我的 Parse 应用程序。我的应用程序有一个部分带有 PFQueryTableViewController。几年来,我禁用
用 PFQueryTableViewController 替换我的 TableViewController 时遇到了一些麻烦,但我通过拉动刷新和分页得到了它。但是,我无法让缓存工作(在 .m 文件的最
新的 Parse Sdks 是否支持 PFQueryTableViewController? 因为我不断收到使用未声明类型 PFQueryTableViewController 的错误。为什么会这样?
我正在使用 Parse.com 编写一个 iOS 应用程序来与服务器交互。 我已经下载并安装了 SKD,正确添加了所有框架,一切正常,直到出现 PFQueryTableViewController。当
我正在按照在线教程使用 Parse 作为后端来创建照片共享应用程序。我已经完成了两次教程,两次都从头开始创建应用程序,但仍然在同一位置出现相同的错误。我四处寻找解决方案,但仍然没有运气。 我正在使用
我的目标是使用 PFQueryTableViewController 设置分页。我会对以下解决方案之一感到满意: 1、表格 View 自动分页。例如,如果 objectsPerPage = 10,当实
我在解析时创建的数据库有问题。我有一张表格,显示了不同地方的里程数(一旦你从 DB 下载了列表),问题是我会订购它以获得向上的距离,但我不知道该怎么做。 - (void)viewDidLoad {
我有一个 PFQueryTableViewController 类型的 TableView ,并从 Parse 云获取其值。表格 View 工作正常,但现在我需要允许用户: 选择一行 在 Parse-
一旦我更新了 Parse SDK 并启用了本地数据存储,我的应用程序中的 PFQueryTableViewControllers 就开始卡在“加载中”。如果我禁用本地数据存储,它们将再次工作。当前将
我正在使用 PFQueryTableViewController,它应该只在用户按下按钮后才加载对象。问题出在 - (PFQuery *)queryForTable 方法上。 这是我的代码: - (P
我是一名优秀的程序员,十分优秀!