tags:

views:

239

answers:

3

Hi All,

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. i.e., 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

+1  A: 

Have you connected the UITableView's delegate and dataSource outlets correctly (either in your nib or using code, depending on how you create the table)?

Fraser Speirs
Yes I have connected the TableView control with the File's owner on the XIB file. Also connected thru code using these line of code :-(void)viewDidLoad{self.title = NSLocalizedString(@"My Worklist", @"WorkListViewController title");self.tblObj.delegate = self;self.tblObj.dataSource = self;self.tblObj.rowHeight = 65;self.tblObj.separatorStyle = UITableViewCellSeparatorStyleSingleLine;self.tblObj.sectionHeaderHeight = 0;}
Amit Jain
A: 

You're close, put this in class A:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.tableView reloadData];
}
Michael Sharek
Thanks but already tried doing this but my viewWillAppear method is not called. I tried a lot but i don't know why this method is not called automatically :o(.
Amit Jain
A: 

I would like to describe the calling of viewControllers in my code: I have a rootViewController (added in mainWindow.xib) the viewWillAppear method of this class is called perfectly. I will give you the caling hiearchy of methods : applicationDidFinishLaunching-->[rootViewController viewdidload]-->in viewDidLoad of rootView i have loaded another viewController that has tabbar on it having 4 classes(A,B,C & D). So by default 1st class (i.e A ) viewDidLoad is called. Class A has a tableView control and added as navigation control so that clicking on any rows navigates to another classes viewControllers (A-->X-->Y..). The problem here is only rootviews viewWillAppear method is called rest of the classes (A or X or Y..) viewWillApperar method is not called. I hope you are not confused ). Please help i am stuck from many days in this problem .

Amit Jain