我正在使用解析,PFQueryTableViewController
内有scrollView
。当我加载应用程序时,数据会显示片刻,然后消失。在我尝试刷新数据后,应用程序立即崩溃。我认为它与subView
的权限/委托有关,因为当表不在scrollView
内时,相同的代码可以工作。该表的代码只是指向我的数据的默认代码
import UIKit
import Parse
import ParseUI
class CustomTableViewControllerA: PFQueryTableViewController {
override init(style: UITableViewStyle, className: String!){
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder){
super.init(coder: aDecoder)
//
self.parseClassName = "Countries"
self.textKey = "nameEnglish"
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("myCell") as! PFTableViewCell!
if cell == nil {
cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "myCell")
}
if let nameEnglish = object?["nameEnglish"] as? String {
cell?.textLabel?.text = nameEnglish
}
if let capital = object?["capital"] as? String {
cell?.detailTextLabel?.text = capital
}
return cell
}
}
scrollView
是使用CustomViewController
var AVC:CustomTableViewControllerA = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("CustomTableViewControllerA") as! CustomTableViewControllerA;
。
self.scrollView.addSubview(AVC.view)
和
self.scrollView.delegate = self
scrollView
/ subView
的框架设置是正确的,我对这部分代码没有任何问题。当没有互联网连接时,代码运行时不会崩溃,它只是处于永久刷新状态。