Question

Is there a way to force viewdidload on poptorootviewcontroller?

I've got an app in which in appdelegate I create a NavigationController and in the RootViewController there's an animation which calls, through locationdidupdate delegate method, many requests to server and then, it pushes another viewcontroller and then the app works normally.

The problem is that during the app there could be the possibility to poptorootviewcontroller, but if I do it, it doesn't start anything, starting from the animation and going on with the requests, so the app doesn't work properly.

My question is:

How can I force viewdidload through the command poptorootviewcontroller?

I tried with viewwillappear, but the flow doesn't work properly.

Any suggestion?

Thanks!

Was it helpful?

Solution

Use NotificationCenter. Ugly way, but task has to be done :)

Have this at the place when you want viewdidload to load again...

[[NSNotificationCenter defaultCenter] postNotificationName:@"ContactListDisappeared" object:self];

in viewWillAppear or viewDidAppear, have

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doTheTaskHere:) name:@"ContactListDisappeared" object:nil];

Set action for this...

- (void)doTheTaskHere:(NSNotification *)notification {
    // call view did load again... 
    [self viewDidLoad];
}

I hope this is what you want.

Today only I wanted something like this and I achieved this way.

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