ios - How can I programmatically unwind 5 controllerViews without a navigation controller? -
i 5 views deep, there no navigation controller binding them. cannot use poptorootviewcontrolleranimated because have no navigation controller. go initial view controller of storyboard, , callback method available after dismiss complete?
objective-c implementation
implement function in appdelegate
or in other util
class
- (void)custompoptorootviewcontroller { uiviewcontroller *topcontroller = [uiapplication sharedapplication].keywindow.rootviewcontroller; //if using method inside appdelegate write self.window.rootviewcontroller nsmutablearray *presentedviewcontrollers = [nsmutablearray array]; while (topcontroller.presentedviewcontroller) { [presentedviewcontrollers addobject:topcontroller.presentedviewcontroller]; topcontroller = topcontroller.presentedviewcontroller; } (uiviewcontroller *vc in presentedviewcontroller) { [vc dismissviewcontrolleranimated:yes completion:nil]; } }
and in current view controller call function.
[(appdelegate*)[uiapplication sharedapplication].delegate custompoptoptorootviewcontroller];