0

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

Tarek Hallak
  • 18,422
  • 7
  • 59
  • 68
user1509593
  • 1,025
  • 1
  • 10
  • 20

1 Answers1

1

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.

dreamzor
  • 5,795
  • 4
  • 41
  • 61