I have a view controller
- In
storyboard, addedtableviewto view controller. - Created an
IBOutletfortableviewto 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
tableviewprotocols-
(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
You should use
reloadDataorreloadSectionsmethods oftableViewin order to reload your tableView from data source.This will call
cellForRowAtIndexPath:methods for every cell to update its data.Here is the reference.