Directly on the code
-(void ) backtorootviewcontroller{uiviewcontroller * vc = [Mainviewcontroller instance] .visibleviewcontroller ; if ([VC Isequal:[mainviewcontroller instance]) return ; if (Vc.presentingviewcontroller ) {[VC dismissviewcontrolleranimated:no completion:^{[self Backtorootviewcontroller]; }]; } else {[Vc.navigationcontroller popViewCon Trolleranimated:no ]; [self Backtorootviewcontroller]; }}
The code above requires an instance object of the root controller, which iterates over the top of the stack until it returns to the root controller, where the animation is not displayed. If you need to display an animation, use Catransaction to control the end of the popviewcontrolleranimated animation and then execute the call again, or it will definitely go wrong. Personally, it's not necessary, and it may take a few seconds for anyone to return to the main page.
Good luck!
IOS back to Rootviewcontroller root controller view