user440096
user440096

Reputation:

Getting -(void) viewDidAppear:(BOOL)animated to be called

I added

-(void) viewDidAppear:(BOOL)animated
{
    NSLog(@"view did appear");
}

to one of my viewcontrollers. Actually they all have them.

When I return from sub viewcontroller 'C' to partent viewcontroller 'B' I would expect to see the viewDidAppear to be called in 'B'.

But it does not get called. It does not get called even in viewcontroller 'A' which is the parent of 'B'.

Is there something I can do to get this working?

The design is a TABBAR controller which has a NAVBAR controller embedded in it.

Many Thanks, -Code

Upvotes: 0

Views: 1043

Answers (2)

Vin
Vin

Reputation: 10548

You will have to write an explicit call to viewDidAppear when you first set-up your tabBarController. For example:

UITabBarController *tabBarController = [[UITabBarController alloc] init];
UINavigationController *navControllerObject = [[UINavigationController alloc]initWithRootViewController:viewControllerObject];
[viewControllerObject viewDidAppear:YES];

You just have to write it while setting up the tabBar and the delegate method would be called as expected, then onwards.

Upvotes: 1

Grady Player
Grady Player

Reputation: 14549

This is going to depend on how you return to your view controller, those delegate methods are sent by the owning view controllers (navigation or tabbar). So if you are not using a (for instance...) navigation controller to push and pop view controllers off of the view stack, then you won't get those messages.

Edit After re reading it sounds like you are using a basic tabbar controller setup, make sure you are letting the tab bar controller do its work by just setting the vc's up.

Upvotes: 1

Related Questions