From b2f3d53519a570dfc169a2937fe74ab9f88ed82a Mon Sep 17 00:00:00 2001 From: Joan Lluch Date: Wed, 22 Apr 2015 12:52:24 +0200 Subject: [PATCH] changes in appearance method behavior --- .../SWRevealViewController.m | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/SWRevealViewController/SWRevealViewController.m b/SWRevealViewController/SWRevealViewController.m index 81c7df6..a657cc3 100755 --- a/SWRevealViewController/SWRevealViewController.m +++ b/SWRevealViewController/SWRevealViewController.m @@ -154,6 +154,20 @@ - (void)prepareRightViewForPosition:(FrontViewPosition)newPosition } +- (void)unloadRearView +{ + [_rearView removeFromSuperview]; + _rearView = nil; +} + + +- (void)unloadRightView +{ + [_rightView removeFromSuperview]; + _rightView = nil; +} + + - (CGFloat)frontLocationForPosition:(FrontViewPosition)frontViewPosition { CGFloat revealWidth; @@ -1540,7 +1554,17 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV _rearViewPosition = newPosition; - return [self _deploymentForViewController:_rearViewController inView:_contentView.rearView appear:appear disappear:disappear]; + void (^deploymentCompletion)() = + [self _deploymentForViewController:_rearViewController inView:_contentView.rearView appear:appear disappear:disappear]; + + void (^completion)() = ^() + { + deploymentCompletion(); + if ( disappear ) + [_contentView unloadRearView]; + }; + + return completion; } // Deploy/Undeploy of the right view controller following the containment principles. Returns a block @@ -1558,7 +1582,17 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV _rightViewPosition = newPosition; - return [self _deploymentForViewController:_rightViewController inView:_contentView.rightView appear:appear disappear:disappear]; + void (^deploymentCompletion)() = + [self _deploymentForViewController:_rightViewController inView:_contentView.rightView appear:appear disappear:disappear]; + + void (^completion)() = ^() + { + deploymentCompletion(); + if ( disappear ) + [_contentView unloadRightView]; + }; + + return completion; }