From bdc9b26454b7164be438566e6ec94d93612f71bf Mon Sep 17 00:00:00 2001 From: Max McLennan Date: Sat, 17 Jan 2015 17:16:56 -0500 Subject: [PATCH 1/2] RNSwipeViewController will now suppress its viewWillAppear method if that method was called while its visibleController was dismissing a presentedViewController --- RNSwipeViewController/RNSwipeViewController.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RNSwipeViewController/RNSwipeViewController.m b/RNSwipeViewController/RNSwipeViewController.m index 57e89ab..f91587c 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 { From eb6ac580f3e705b7977c6af14973e8202a1f604b Mon Sep 17 00:00:00 2001 From: Max McLennan Date: Tue, 20 Jan 2015 20:29:13 -0500 Subject: [PATCH 2/2] Added @property BOOL swipingDisabled to the RNSwipeViewController. Setting it to true prevents the swipeController from switching to another sub-controller until it is reset back to false or one of the canShowRight, canShowLeft, canShowBottom properties is explicitly set to true. --- RNSwipeViewController/RNSwipeViewController.h | 8 ++++++ RNSwipeViewController/RNSwipeViewController.m | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+) 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 f91587c..8debfff 100644 --- a/RNSwipeViewController/RNSwipeViewController.m +++ b/RNSwipeViewController/RNSwipeViewController.m @@ -391,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 {