2

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

respondsToSelector:]: 消息发送到已释放实例 0x79a96e20

如果我加载 tableview 所在的 ViewController(没有嵌入到容器视图中)它就可以工作,这让我认为这与父 viewcontroller 完成其加载过程后未分配的 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;
        }
}
4

0 回答 0