I will directly start from an ex: I have two classes A and B, both are derived from UITableViewController.
I have also added them into navigation controller so there is navigation going on from A to B. These both classes use database for showing data into the table. Now in B View I delete a row from the DB and A view displays the row count of that DB table. Now what I am doing is on the BACK button of the navigation I want to I am calling this method TRY 1:
//in class B
-(IBAction)backBtnPressed
{
[ObjA.tbleView reloadData];
[self.navigationController popViewControllerAnitmated:YES];
}
on its action. The problem is this method does not reload the data of View A. ie, it doesn't call the tbleView's delegate methods like cellForIndexPath...etc. Then I thought that may the reloadData shud be called from the same class so did this TRY 2:
//in class B
-(IBAction)backBtnPressed
{
[ObjA.tbleView myReloadData];
[self.navigationController popViewControllerAnitmated:YES];
}
//Class A
-(void)myReloadData
{
[self.tbleView reloadData];
}
It comes into this method but still doesn't call the tableView delegate methods. Please let me know why I am not able to do this silly thing :(. Regards.. Amit
您是否已正确连接UITableView
的delegate
出口和dataSource
出口(在您的笔尖中还是使用代码,取决于创建表的方式)?
You're close, put this in class A:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.