Removing UIViewControllers

If you would like to remove the current UIViewController from the view stack once a new one has been navigated to the removeCurrent property of SimpleIOSViewStackNotificationVO can be set using one of the two initialisers.

[[NSNotificationCenter defaultCenter]                          
        postNotificationName:@"show_a_new_view_controller"
                               object:[

                                                [SimpleIOSViewStackNotificationVO alloc]

                                                      initWithAnimationFlag:YES
                                                               AndRemoveFlag:YES

                                               ]

                                   ];

[[NSNotificationCenter defaultCenter]
        postNotificationName:@"show_a_new_view_controller"
                              object:[

                                                [SimpleIOSViewStackNotificationVO alloc]

                                                      initWithAnimation:YES
                                                          removeCurrent:YES
                                                            recycleTarget:YES
                                                      dictionaryForView:nil

                                               ]

                                   ];

If you use the older initialiser (the one with initWithAnimationFlag) the value of recycleTarget will be YES.

Provided that you have no other references to the current UIViewController elsewhere this should result in the dealloc method being run and the memory released shortly after the target becomes the new current UIViewController.

In certain situations the removeCurrent flag can be used to control the direction of the animation. When recycling the target if the current UIViewController is to be removed then the animation moves from left to right, as if going backwards and all UIViewControllers in between the current and the target are also removed. This is the same as calling popToViewController on a UINavigationController.

If the current is to not be removed the target is first removed and replaced on the stop of the stack and the animation moves forward, right to left.