Cruces Cruces - 1 year ago 75
iOS Question

Adding a Wizard style ViewController between two NavigationViewControllers in IOS

I am trying to translate an application I made in Android to IOS and I'm having a little problem.

Normally when the user selects what they want to do, there are one to x number of screens that ask them security questions to verify certain things (their location their identity etc)

In Android what I do when I reach that part is create a new Activity, show it, and then that activity handles the next question that should be asked, and how it should be presented, and then adds a fragment to itself as a main view and sends that fragment initialisation info (what the question is what the answers are allowed to be etc)

After that I remove the Activity from the stack, update some of my Application's static variables with the information and start a new Activity to do the actual work

How can I achieve this with IOS (I'm using Xamarin.IOS but I can understand XCode code if you have code samples there)

What I've done so far is create a new navigation view controller and add the QuestionController programmatically which loads another QuestionController programmatically, unfortunately this creates a back button which I do not want. And if I don't use a new navigation view controller the QuestionControllers get added to the previous navigation controllers.

I also tried showing the QuestionControllers as Modal but I can't seem to achieve this whole older question slides out while the new question slides in look.

Thanks in advance for any help you can provide

Answer Source


I don't know Xamarin, this is from an Xcode, Objective-c / Swift point of view (as you've mentioned you understand Xcode).

What I would recommend is to look at the UIPageViewController. This viewController manages a collection of viewControllers as children. Allows you to animate transitions between them etc. I believe this will accomplish the same effect as your fragment approach.

As for the removing, I would present the UIPageViewController modally, on top of another screen. Then when the setup is finished, you can dismiss the entire wizard in 1 action without having to worry about the back button, and return to the screen underneath.