Reputation: 122
I have a table View and a uibutton.
When i click on uibutton, it will display a model view control using presentModelviewcontroller
method.
I have a text field and save button in the presentmodelview.
Please let me know how to reload table view when the user click's on presentmodelview save button
Upvotes: 0
Views: 529
Reputation: 1522
when you want reload tableview please use below line
[self.tableView reloadData];
Upvotes: 0
Reputation: 372
In a nutshell,
YourViewControllerClass * vc = [[YourViewControllerClass alloc]init];
[self presentViewController:vc animated:NO completion:nil];
Hope this helps :)
Upvotes: 0
Reputation: 16276
First add the item to the array, then reload your table view.
Assuming you declared all properties needed including the array used by the data source.
@property(nonatomic, retain)NSMutableArray *modalArray;
The IBAction on Save button should include the following code:
//Add the item to the array
[self.modalArray addObject:[NSString stringWithFormat:@"%@",txtField.text]];
//Rest of your code, dismiss the modal view
Once dismissed, you need to reload the table view to show up the recent value saved on the modal view.
[self.yourTableView reloadData];
reloadData
will call implicitly the data source method tableView:cellForRowAtIndexPath:
which will loop the array again and so show you the new value.
Upvotes: 0
Reputation: 11
If you need the presentModalViewController
to be removed and then the tableView to be reloaded then use this
[yourTableView reloadData];
on the viewWillAppear of the initial view.
Upvotes: 1