简体   繁体   中英

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. The center view is a UITableView and the left panel is a view in which I call a method (by pressing a button)

- (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.

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? 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:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM