Reload button on navigation controller on window.xib
heres my issue, I have a tabbar as the root controller, I the开发者_如何学Gon have tabs which are navigation controllers. ( all this is done in Interface Builder )
each navigation controller has a view controller. one of these view controllers have a table view.
on the navigation controller of this table view, I want a item button which reloads the table view.
i know to use reloadData.
I have linked the item button up to a IBAction in the view controller of the navigation controller by making a new NSObject in the mainWindow.xib pointing to this view controller. in the view controller I have this IBAction
-(IBAction)reloadTable:(id)sender
{ NSLog(@"RELOADDDDING"); [self.tableViewIB reloadData]; }
The NSlog is displayed, but the table is not reloading.
I have tried with and without the self.
I had the exact same setup with the exact same issue. Below is how I fixed it. Put this code in the view controller with the Table.
- (void)viewWillAppear:(BOOL)animated {
//reload table now that we have a good array to show
[self.view reloadData];
[super viewWillAppear:animated];
}
Updated in response to your comment
Add this code to the action of your button being pushed
//button was pushed code
TableViewController * vc = (TableViewController *)[[TableViewController alloc] init];
//this tableview should be named whatever you have your table named as.
[vc.tableView reloadData];
[vc release];
I had asked the exact same question few minutes back - - - This might be a simple question. HELP with Resetting UITableViewCells
Just do this !
- Assign
TableView
as a property. - Reload it in
ViewWillAppear
精彩评论