子视图中的操作崩溃应用程序

时间:2015-06-29 13:45:52

标签: ios swift parse-platform subviews

我正在使用解析,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的框架设置是正确的,我对这部分代码没有任何问题。当没有互联网连接时,代码运行时不会崩溃,它只是处于永久刷新状态。

0 个答案:

没有答案