Question

In my application, I have a TabBarController (which has 3 ViewControllers as tabBarItems) that is presented from another ViewController (Called HomeViewController). The HomeViewController has three buttons, which on being pressed shows the respective controller in the tabBarController.

The Controller in the second tabBarItem processes some info and sends that info to the controller in the first tabBarItem, which that updates its table and shows the processed data. However, the problem is the ViewDidLoad method of first controller.

In it's viewDidLoad method, i am hiding the table initially, so that if the user clicks the first button on the HomeViewController, the empty table isn't visible to him. This goes according to plan in case if the user clicks the first button on HomeViewController (to present the first view controller)

The issue is: if the user first goes to the second viewController from the HomeViewController, then the viewDidLoad method of it is called (which is not an issue). However, when the user goes to the first Viewcontroller from the second ViewController, the viewDidLoad method of the first Viewcontroller is called, and my table is hidden..!! which needs to be actually shown.

I know my problem is hard to understand this way, but can anyone please help??

here's the code of my first ViewController:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"View Did Load of CCVC");

    //self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top_bar.png"]];

    [self.customercareSearchbar setBackgroundImage:[UIImage imageNamed:@"dark_grey_search_back.png"]];

    [self.view addSubview:self.customercareSearchbar];
    [self.view addSubview:self.customerCareTableView];

    self.customercareSearchbar.delegate = self;
    self.customerCareTableView.delegate = self;

    //[self.customerCareTableView setBackgroundColor:[UIColor lightGrayColor]];
    [self.customerCareTableView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];

     ////HERE LIES THE Main PROBLEM

    [self.customerCareTableView setHidden:YES];
    [self.customercareSearchbar becomeFirstResponder];
}

IS it possible to move

[self.customerCareTableView setHidden:YES];
    [self.customercareSearchbar becomeFirstResponder];

in any other method?? i know it won't work in init because the views are loaded after init is called..

Was it helpful?

Solution

You can add some logic based on values you receive from second ViewController, in ViewWillAppear of your First ViewController, so as to set your customerCareTableView hidden property to NO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top