0
votes

I have a view controller

  • In storyboard, added tableview to view controller.
  • Created an IBOutlet for tableview to View controller's header file.
  • The view controller's header file includes an resultsarray
  • Changed the @interface to include delegates UITableViewDelegate, UITableViewDataSource
  • View controller implementation file has mandatory tableview protocols

    • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

    • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

    • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

The view controller has search button in storyboard and IBAction in view controller header file. On click of search button, results are obtained. How do I load the array and redisplay tableview with results in search method. After I loaded the results in array, I tried [self viewdidload];, hoping the cells will be loaded. But didn't. I thought of calling [self.detailView cellForRowAtIndexPath:?indexpath], but dontknow what the value of index path is. Appreciate help from guru's to load the UItableviewcell

Thanks

1
You linked your uitableview's delegate and datasource to your view controller in your storyboard?Simon Germain

1 Answers

1
votes

You should use reloadData or reloadSections methods of tableView in order to reload your tableView from data source.

// you fill your array with results here...
// and then call
[tableView reloadData];

This will call cellForRowAtIndexPath: methods for every cell to update its data.

Here is the reference.