[英]ios cellForRowAtIndexPath doesn't get called however numberOfRowsInSection gets called and returns a number
My application is using JASidePanels libraries and I had set them using storyboard. 我的应用程序使用JASidePanels库,并且使用情节提要设置了它们。 The center view is a UITableView and the left panel is a view in which I call a method (by pressing a button)
中心视图是UITableView,左面板是我调用方法(通过按按钮)的视图
- (IBAction)reloadAllFilters:(UIButton *)sender{
MasterViewController *masterController = [self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"];
NSMutableArray *arrayOfFilterIds = [[NSMutableArray alloc] init];
// another code
masterController.filterIdsToDisplay = arrayOfFilterIds;
[masterController.tableView reloadData];
[self.sidePanelController toggleLeftPanel:self];
} }
The thing is, that when the app starts, the number of rows returned by number, but after I call this method, the number of rows is 30 but I cant see nothing. 问题是,当应用程序启动时,行数由数字返回,但是在我调用此方法后,行数为30,但看不到任何内容。
I think that the problem is that I am instantiating a new masterController and therefor I cant get the actual table view to be displayed? 我认为问题在于我正在实例化一个新的masterController,因此无法获得要显示的实际表视图? Or am I wrong?
还是我错了? Can you please help me?
你能帮我么?
Yes you are right. 是的,你是对的。 You create a new master controller every time you call the method
每次调用该方法时,都会创建一个新的主控制器
From UIStoryboard reference: 从UIStoryboard参考:
This method creates a new instance of the specified view controller each time you call it.
每次调用时,此方法都会创建指定视图控制器的新实例。
You need to get the existing one. 您需要获取现有的一个。
Please set the delegate and datasource to your tableview like this ... 请像这样将委托和数据源设置为您的表视图...
tableView.delegate = masterController;
tableView.dataSource = masterController;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.