0
votes

I have a password viewcontroller which is presented always when app is activated.

I have another viewcontroller which is presented on click of a button. In this there is a process to be shown and once it is complete dissmiss itself.

The scenario is:

1) Present this view contoller, process starts.

2) Before this process is finished, press home button.

3) Now open app again.

4) Password viewcontroller is presented, as it is mandatory.

5) At this time that process started in step 1 completes. Dismiss method is called. But Password view controller is dismissed instead of this process VC.

How can I dismiss particular presented VC?

**Edit:**

I tried a different way for this. When I present passcodeVC from appdelegate, I create a new navigation and set it to rootViewController. Earlier nav is stored in a reference. Here I succeded in keeping passcode view. Passcode view is not dismissed now.

When user enters passcode then I change rootviewcontroller again to old. I thought this will work. But, it does not. MailVc is dismissed. And when I try to present mailVC again, it says this is already presented.

Seems like, since I change rootVC, and then dissmissVC is called when it is not present in view. Can some one explain me this.

Thanks.

1
Did you try delegate pattern? Also for doing process dont present as controller, or if you are doing that just save the progress when application is entering into background and dismiss the progress controllerRetro
Yes. I solved the problem using delegate. But I wanted to know the edited question. Why this happened. When view is not in window root and dismiss is called. View is dismissed. But later when I try to present again, It says already presenting. Even I created new instance of that class to present.Durgaprasad
As you root controller the rootVC has presented the view, so when you set it again before changing the rootVC just dismiss the progress VC or as I told you when application is entering into background.Retro

1 Answers

0
votes

Before dismissing the current view controller, you can test its type. If it is kindOfClass (YourPasswordViewController), don't dismiss it. Otherwise, dismiss away.

From you UIViewController that does the calculation and dismisses the current UIViewController, do the following.

Get instance to your UINavigationController. Get viewControllers property. It's an NSArray. Access the last UIViewController and test if it's object of PasswordUIViewController. If it is, then don't dismiss it.