如果从ContainerView加载,UITableView崩溃

时间:2014-07-17 09:04:47

标签: xcode uitableview swift container-view xcode6

我在一个容器视图中加载了一个与tableview(在IB中制作的原型单元格)相关的重大问题。它加载完美,但当我尝试点击或滚动它只是崩溃与

  

respondsToSelector:]:发送到解除分配的实例0x79a96e20的消息

如果我加载了Viewview的tableController(没有嵌入到容器视图中),它就可以工作了,这让我觉得这与tableview在父视图控制器完成加载过程后未分配有关。

我对此非常陌生,这让我很生气!!

感谢您的帮助。

(THE VIEWCONTROLLER WHICH FILLS THE CONTAINERVIEW)

class cgGameViewerController: UIViewController {

    @IBOutlet var cgGame:UIView;  //Connected to IB ContainerView

    override func viewDidLoad() {
        var cgGameController=self.storyboard.instantiateViewControllerWithIdentifier("myIBviewController") as cgGameViewController;
        self.cgGame.addSubview(cgGameController.view);    
        super.viewDidLoad()
    }        

}


(THE VIEWCONTROLLER WHICH IS LOADED IN A CONTAINERVIEW. In IB, UITableView delegate and datasource, is attached to the viewcontroller)

class cgGameViewController: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate,UITableViewDelegate,UITableViewDataSource {

        func tableView(tableView:UITableView!, numberOfRowsInSection section:Int) -> Int {
            return 5;

        }

        func tableView(tableView:UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) -> UITableViewCell! {
            var myCell:UITableViewCell=tableView.dequeueReusableCellWithIdentifier("myCellInIB", forIndexPath: indexPath) as UITableViewCell;
            return myCell;
        }
}

0 个答案:

没有答案