diff --git a/RNSwipeViewController/RNSwipeViewController.h b/RNSwipeViewController/RNSwipeViewController.h index efd7752..5d8f907 100644 --- a/RNSwipeViewController/RNSwipeViewController.h +++ b/RNSwipeViewController/RNSwipeViewController.h @@ -240,6 +240,14 @@ extern NSString * const RNSwipeViewControllerCenterDidAppear; */ @property (assign, nonatomic) BOOL canTapOut; +/** Disable/Enable swiping to all other controllers besides the current one. + + @see canShowLeft + @see canShowRight + @see canShowBottom + */ +@property (assign, nonatomic) BOOL swipingDisabled; + ///--------------------------------------------------------------------------------------- /// @name Controller Delegates ///--------------------------------------------------------------------------------------- diff --git a/RNSwipeViewController/RNSwipeViewController.m b/RNSwipeViewController/RNSwipeViewController.m index 57e89ab..8debfff 100644 --- a/RNSwipeViewController/RNSwipeViewController.m +++ b/RNSwipeViewController/RNSwipeViewController.m @@ -176,8 +176,10 @@ - (void)viewDidLoad { } - (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - [self _layoutContainersAnimated:NO duration:0.f]; + if (! self.visibleController.presentedViewController.isBeingDismissed) { + [super viewWillAppear:animated]; + [self _layoutContainersAnimated:NO duration:0.f]; + } } - (void)viewDidLayoutSubviews { @@ -389,6 +391,32 @@ - (void)setBottomVisibleHeight:(CGFloat)bottomVisibleHeight { } } +- (void)setSwipingDisabled:(BOOL)swipingDisabled { + + BOOL leftEnabled = ! swipingDisabled; + BOOL rightEnabled = ! swipingDisabled; + BOOL bottomEnabled = ! swipingDisabled; + + switch (self.visibleState) { + case RNSwipeVisibleLeft: + leftEnabled = YES; + break; + case RNSwipeVisibleRight: + rightEnabled = YES; + break; + case RNSwipeVisibleBottom: + bottomEnabled = YES; + break; + case RNSwipeVisibleCenter: + break; + } + self.canShowLeft = leftEnabled; + self.canShowRight = rightEnabled; + self.canShowBottom = bottomEnabled; + + _swipingDisabled = swipingDisabled; +} + #pragma mark - Getters - (UIViewController*)visibleController {