1

In my application I have a UINavigationController, After authentication I run perform segue(Push replace) for navigating to UINavigationController, when app goes to background I present Authentication page again, I do this in a classed I named it ScreenLocker

 UIApplication.shared.keyWindow?.rootViewController = vcAuthentication

But after n time's app goes to background I have n UINavigationControllers and one Authentication controller (when I saw debug view hierarchy I found it), know for showing UINavigationController How can I remove Authentication view controller?

enter image description here

enter image description here

My current view controller is highlighted view controller, it's in front of all views, I want to remove it and showing another views.

enter image description here

Hamed
  • 1,678
  • 18
  • 30
  • Can you share the code how you are initializing the navigation controller? – Harjot Singh Feb 23 '19 at 08:04
  • performSegue(withIdentifier: R.segue.authenticationViewController.authenticationToCardList.identifier, sender: self) – Hamed Feb 23 '19 at 08:10
  • I think it's because of changing root view controller, I mentioned it in my question – Hamed Feb 23 '19 at 08:12
  • Rather using code, did u try it with storyboard? Try it with storyboard and let me know if the problem is still there? – Harjot Singh Feb 23 '19 at 08:13
  • You are changing the rootviewcontroller in appdelegate only right? – Harjot Singh Feb 23 '19 at 08:15
  • Changing view controller depend on many things, I can't handle it in storyboard. – Hamed Feb 23 '19 at 08:16
  • No I changed it on another class, I have a class I named it screen locker, it's time base, after 1 minutes I lock app automatically – Hamed Feb 23 '19 at 08:19
  • May be before that class you have to make the current navigationcontroller to nil. – Harjot Singh Feb 23 '19 at 08:20
  • This is happening because you are initializing the navigationcontroller in appdelegate as well as in screenlocker class, this what i understood? – Harjot Singh Feb 23 '19 at 08:22
  • I don't want to pass navigation controller to this class:-( – Hamed Feb 23 '19 at 08:23
  • @Mr Hamed you need to provide the code what you are doing in appdelegate and in this class, i am not able to get the scenario what you are working on? – Harjot Singh Feb 23 '19 at 08:24
  • It seems there is a way to get all controllers in the app!! I'll find this – Hamed Feb 23 '19 at 08:24
  • It seems to me, you playing with rootviewcontroller, which will overwrite the current rootviewcontroller everytime you did. – Harjot Singh Feb 23 '19 at 08:27
  • Question updated – Hamed Feb 23 '19 at 18:18
  • Updating the question with screenshot doesn't help unless, i don't see the code what you are doing beneath,see i have no idea how you are transitioning, how you are locking the screen, as you have mentioned you are changing the rootviewcontroller sometimes, so share the code so that we can help to remove your VCs which you don't want. – Harjot Singh Feb 24 '19 at 06:03
  • In the screenshot, i see many VCs overlapping each other. – Harjot Singh Feb 24 '19 at 06:04

0 Answers0