Pop to root view slider in application delegate

I have an application in which someone logs into the system, and if they run it after sending it to the background for more than 10 minutes, I go out to a small little warning "session expired" and send it to the root view controller (login page) ,

Everything works fine, but I don’t know how to float to the root view controller in the navigation controller stack from the application delegation application WillEnterForeground: method.

I tried saving money with the navigationController on the appDelegate variable, but I'm wondering if the application has been running in the background for several days if iOS starts to release some variables, because at this time I get an error in this method.

Any ideas?

+4
source share
2 answers

If the navigation controller is the root application controller of your application, you can get it as:

UINavigationController *myNavCon = (UINavigationController*)self.window.rootViewController; 

where self is in the application delegate

+9
source

To make things more understandable, you can use the following command for popviewcontroller from AppDelegate

 UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController; [navigationController popToRootViewControllerAnimated:YES]; 

Here self is the delegate of the application.

+3
source

Source: https://habr.com/ru/post/1436647/


All Articles