several tableviews in one view

橙三吉。 提交于 2019-12-25 05:12:57

问题


I am trying to make a view that contains several tableViews in it - basically a week calendar view that each day is a tableView that shows the events of that day.

In the storyboard I'v added to the view a tableView and tried to connect it in two different ways in the viewDidLoad:

DaysTableViewController * tvc = [[DaysTableViewController alloc]  initWithStyle:UITableViewStylePlain];
self.dayView.delegate = tvc;
self.dayView.dataSource = tvc;

or:

DaysTableViewController * tvc = [[DaysTableViewController alloc] initWithStyle:UITableViewStylePlain];
self.dayView = tvc.tableView;

when dayView is my IBOutlet property for the tableView in the storyboard. but it crash in both ways, and I dont know where it crash in the code.

I know the DaysTableViewController itself works fine, because when I push it in a NavigationController it works.

Am I doing something wrong?


回答1:


You need to use TableViews inside a ViewController, not a TableViewController. A TVC can only have one tableview.




回答2:


I'v found the problem. it was a simple memory management problem, I mad the Object that was the dataBase in the ViewDidLoad and didn't have a strong property for it, and just got released... thanks everyone for the answers.



来源:https://stackoverflow.com/questions/9814278/several-tableviews-in-one-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!