简体   繁体   English

iOS的cellForRowAtIndexPath没有被调用但是numberOfRowsInSection被调用并返回一个数字

[英]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.

相关问题 cellForRowAtIndexPath永远不会被调用,但是numberOfRowsInSection是 - cellForRowAtIndexPath never gets called, but numberOfRowsInSection is 未调用 cellForRowAtIndexPath 但调用了 numberOfRowsInSection - cellForRowAtIndexPath not called but numberOfRowsInSection called numberOfRowsInSection返回大于0的值; cellForRowAtIndexPath仍然没有被调用 - numberOfRowsInSection returns more than 0; cellForRowAtIndexPath still not being called numberOfRowsInSection多次调用,但从未调用cellForRowAtIndexPath - numberOfRowsInSection called multiple times but cellForRowAtIndexPath never called 在reloadData之后没有调用cellForRowAtIndexPath但是numberOfRowsInSection没有调用 - cellForRowAtIndexPath not called after reloadData but numberOfRowsInSection does CellForRowAtIndexPath被意外调用 - CellForRowAtIndexPath gets called unexpectedly 当numberOfRowsInSection等于零时强制调用cellForRowAtIndexPath - Force cellForRowAtIndexPath to be called when numberOfRowsInSection equals to zero 孩子的numberOfRowsInSection函数没有被调用? - Child's numberOfRowsInSection function doesn't be called? 未调用cellForRowAtIndexPath,但为UITableView调用的numberofRowsInSection已添加为UIView的子视图 - cellForRowAtIndexPath not called but numberofRowsInSection called for UITableView added as subview to UIView ios,未调用tableview cellForRowAtIndexPath - ios, tableview cellForRowAtIndexPath not called
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM