reload tableview from navigation controller
I am new to iPhone development.
I have a navigation controller which loads a tableview. The class identity of the tableview is a tableViewController class.
I want to know how to refresh the table view from the navigation controller.
I know within the tableViewController i can use the
[self.tableView reloadData];
Sorry if i am vague. Thanks in advance.
after feedback:
Here is the navigation controller
@interface slNavController : UINavigationController{
UIToolbar *toolbar;
slTableViewController *tableVC;
}
@property(nonatomic, retain) slTableViewController *tableVC;
where slTableViewController is the Delegate of the tableView that needs to be refreshed.
and where i needed to refresh the table i used
[tableVC.tableView reloadData];
Here is slTableViewController header
@interface slTableViewController : UITableViewController <UITableViewDelegate,UITableViewDataSource> {
IBOutlet UITableView *slTableView;
NSMutableArray *list;
TryAppDelegate *appDelegate;
//UIToolbar *toolbar;
IBOutlet UITextField *textField;
}
But 开发者_JAVA技巧still not able to refresh the tableview.
There must be some viewController which is the delegate of the tableView. Send reloadData to that controller, e.g.
[viewController.tableView reloadData];
If you know where in the stack the viewController is, you can access it through the navController. For instance, if it happens to be the rootViewController, then you can do
HomesViewController *homesController = [[[self navigationController] viewControllers] objectAtIndex:0];
If it is Navigation based application you want to reload the data of table view, You have to write in view will appear like this
[self.tableView reloadData];
Give your navigationController a pointer to the tableViewController.
In the .h file:
@property(nonatomic, retain) YourTableViewController *tableViewController;
Then when you want to reload data:
[tableViewController.tableView reloadData];
精彩评论