1111#import < objc/runtime.h>
1212
1313@interface PPRevealSideViewController (Private)
14+ - (void ) setRootViewController : (UIViewController *)controller replaceToOrigin : (BOOL )replace ;
1415- (void ) setRootViewController : (UIViewController*)controller ;
1516- (void ) addShadow ;
1617- (void ) removeShadow ;
@@ -371,7 +372,7 @@ - (void) popViewControllerWithNewCenterController:(UIViewController *)centerCont
371372 if (finished) {
372373 CGRect oldFrame = _rootViewController.view .frame ;
373374 centerController.view .frame = oldFrame;
374- [self setRootViewController: centerController];
375+ [self setRootViewController: centerController replaceToOrigin: NO ];
375376
376377 // this is the anim block to put to normal the center controller
377378 void (^smallAnimBlock)(void ) = ^(void ) {
@@ -394,7 +395,7 @@ - (void) popViewControllerWithNewCenterController:(UIViewController *)centerCont
394395
395396
396397 _animationInProgress = NO ;
397-
398+
398399 if (controllerToPush) {
399400 [self pushViewController: controllerToPush
400401 onDirection: direction
@@ -569,7 +570,8 @@ - (PPRevealSideDirection) sideDirectionOpened
569570
570571#pragma mark - Private methods
571572
572- - (void ) setRootViewController : (UIViewController *)controller {
573+ - (void ) setRootViewController : (UIViewController *)controller replaceToOrigin : (BOOL )replace
574+ {
573575 if (_rootViewController != controller) {
574576 [self willChangeValueForKey: @" rootViewController" ];
575577
@@ -584,32 +586,37 @@ - (void) setRootViewController:(UIViewController *)controller {
584586 @finally {
585587
586588 }
587-
589+
588590 if ([[[UIDevice currentDevice ] systemVersion ] floatValue ] < 5.0 ) [_rootViewController viewWillDisappear: NO ];
589591 [_rootViewController.view removeFromSuperview ];
590592 if ([[[UIDevice currentDevice ] systemVersion ] floatValue ] < 5.0 ) [_rootViewController viewDidDisappear: NO ];
591-
593+
592594 _rootViewController = PP_RETAIN (controller);
593595 _rootViewController.revealSideViewController = self;
594-
596+
595597 [self handleShadows ];
596598
597599 if ([[[UIDevice currentDevice ] systemVersion ] floatValue ] < 5.0 ) [_rootViewController viewWillAppear: NO ];
598600 [self .view addSubview: _rootViewController.view];
599601 if ([[[UIDevice currentDevice ] systemVersion ] floatValue ] < 5.0 ) [_rootViewController viewDidAppear: NO ];
600-
602+
601603 [_rootViewController addObserver: self
602604 forKeyPath: @" view.frame"
603605 options: NSKeyValueObservingOptionNew
604606 context: NULL ];
605607
606608 [self addGesturesToCenterController ];
607-
608- _rootViewController.view .frame = self.view .bounds ;
609+
610+ if (replace)
611+ _rootViewController.view .frame = self.view .bounds ;
609612
610613 [self didChangeValueForKey: @" rootViewController" ];
611614 }
612615}
616+ - (void ) setRootViewController : (UIViewController *)controller
617+ {
618+ [self setRootViewController: controller replaceToOrigin: YES ];
619+ }
613620
614621- (void ) addShadow
615622{
0 commit comments