Basic Use

SimpleIOSViewStack is very easy to use. It is a sub classed UINavigationController, you use it in the same place in your application, initialise it similar ways and size and display it to users identically. Two of the UINavigationController initialisers are available :

[[alloc] init]

and

[[alloc] initWithNavigationBarClass:toolbarClass:]

Sizing and adding to a view is exactly as expected. For example in a rootViewController class :

_viewStack = [[ApplicationViewStack alloc] init];

[self addChildViewController:_viewStack];

_viewStack.view.frame = self.view.frame;
 [self.view addSubview:_viewStack.view];
 

Once you have an instance you begin to register UIViewControllers with it and link them to NSStrings. These NSStrings will be posted as NSNotification names when application logic determines that a specific UIViewController be shown.

The link between the UIViewController and the NSString is created with a SimpleIOSViewStackVO. This object is a Value Object in that it is a straight forward NSObject encapsulating a number of properties which are set at initialisation time and after that are "read only". In other words, it is immutable.  You create one and register it will the views stack for every UIViewController the view stack is required to manage.

SimpleIOSViewStackVO *__classViewStackVO = [[SimpleIOSViewStackVO alloc]
                initWithNotificationString:@"show_class_view_controller"
                        viewControllerClass: [ClassViewController class]
                                 storyboardID:nil
                            storyboardName:nil
                                       nibName:nil];
       
        [self registerViewStackVO:__classViewStackVO];

If a NSNotification is posted with a name that matches an NSString previously registered against a UIViewController sub class then that SimpleIOSViewStack will “display” it. Of course if that SimpleIOSViewStack is not visible at the time then it will not become visible until such time that the view stack itself is show, hence the speech marks above.

[[NSNotificationCenter defaultCenter] postNotificationName:@"show_class_view_controller" object: nil];

It's that easy.  

In fact I do something very similar to this code example all the time in my projects. I create a view stack and do the registering in an init method and in viewDidLoad I post the notification to show the default UIViewController for that view stack.

If you register a second UIViewController and on tap of a button, for example, post a notification with the name NSString matching the string of the second one it appears when you tap the button. Couldn't be any more straight forward. The back button appears in the nav bar as you would expect and the swipe from the edge of the screen to go back also works as expected provided you are not using custom left buttons in the nav bar.

 - (IBAction)gotoScreenTwo:(id)sender {
   
    [[NSNotificationCenter defaultCenter]
     
        postNotificationName: @"show_class_view_controller"
                        object: [

                                                [SimpleIOSViewStackNotificationVO alloc]        
                                               
                                                                        initWithAnimationFlag:YES
                                                                                  AndRemoveFlag:NO

                                     ]
     
                        ];
   
}