From b5a1af5485a297d075a070f95ba9a5e478dfccfd Mon Sep 17 00:00:00 2001 From: Burnie777 Date: Wed, 19 Jul 2017 09:07:34 +0200 Subject: [PATCH 1/5] added support for Main & Specific controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Main… I have many cases where my main menu is not the root controller… In the case of this update, my Main controller is after a load screen which makes the app load faster in the long run… Specific controller… I also needed to just hide a menu on a specific screen and show another view from there. Thus I added this for a bit of comfort in the whole process… --- SlideMenu/Source/SlideNavigationController.h | 5 ++ SlideMenu/Source/SlideNavigationController.m | 95 ++++++++++++++++++++ 2 files changed, 100 insertions(+) mode change 100644 => 100755 SlideMenu/Source/SlideNavigationController.h mode change 100644 => 100755 SlideMenu/Source/SlideNavigationController.m diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h old mode 100644 new mode 100755 index b64701b..85057b0 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -68,6 +68,11 @@ extern NSString *const SlideNavigationControllerDidReveal; - (void)popToRootAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; - (void)popAllAndSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion; - (void)popAllAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; +- (void)popToMainAndSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion; +- (void)popToMainAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; +- (void)popToController:(UIViewController *)goToController andSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion; +- (void)popToController:(UIViewController *)goToController andSwitchToViewController:(UIViewController *)viewController andCompletion:(void (^)())completion; + - (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)openMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)closeMenuWithCompletion:(void (^)())completion; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m old mode 100644 new mode 100755 index d7409a6..fe08287 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -30,6 +30,8 @@ typedef enum { PopTypeAll, + PopTypeMain, + PopTypeController, PopTypeRoot } PopType; @@ -222,6 +224,12 @@ - (void)switchToViewController:(UIViewController *)viewController if (poptype == PopTypeAll) { [self setViewControllers:@[viewController]]; } + else if (poptype == PopTypeMain){ + NSArray *arr = [self viewControllers]; + + [super popToViewController:[arr objectAtIndex:1] animated:NO]; + [super pushViewController:viewController animated:NO]; + } else { [super popToRootViewControllerAnimated:NO]; [super pushViewController:viewController animated:NO]; @@ -267,6 +275,64 @@ - (void)switchToViewController:(UIViewController *)viewController } } +- (void) popToViewController:(UIViewController *)goToController + andSwitchToViewController:(UIViewController *)viewController + withSlideOutAnimation:(BOOL)slideOutAnimation + popType:(PopType)poptype + andCompletion:(void (^)())completion +{ + if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class]) + { + [self closeMenuWithCompletion:completion]; + return; + } + + void (^switchAndCallCompletion)(BOOL) = ^(BOOL closeMenuBeforeCallingCompletion) { + if (poptype == PopTypeController){ + [super popToViewController:goToController animated:NO]; + [super pushViewController:viewController animated:NO]; + } + + if (closeMenuBeforeCallingCompletion) + { + [self closeMenuWithCompletion:^{ + if (completion) + completion(); + }]; + } + else + { + if (completion) + completion(); + } + }; + + if ([self isMenuOpen]) + { + if (slideOutAnimation) + { + [UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0 + delay:0 + options:self.menuRevealAnimationOption + animations:^{ + CGFloat width = self.horizontalSize; + CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width; + [self moveHorizontallyToLocation:moveLocation]; + } completion:^(BOOL finished) { + switchAndCallCompletion(YES); + }]; + } + else + { + switchAndCallCompletion(YES); + } + } + else + { + switchAndCallCompletion(NO); + } +} + - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion { [self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeRoot andCompletion:completion]; @@ -298,6 +364,35 @@ - (void)popAllAndSwitchToViewController:(UIViewController *)viewController [self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeAll andCompletion:completion]; } + +- (void)popToMainAndSwitchToViewController:(UIViewController *)viewController + withSlideOutAnimation:(BOOL)slideOutAnimation + andCompletion:(void (^)())completion +{ + [self switchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeMain andCompletion:completion]; +} + +- (void)popToMainAndSwitchToViewController:(UIViewController *)viewController + withCompletion:(void (^)())completion +{ + [self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeMain andCompletion:completion]; +} + +- (void) popToController:(UIViewController *)goToController +andSwitchToViewController:(UIViewController *)viewController + withSlideOutAnimation:(BOOL)slideOutAnimation + andCompletion:(void (^)())completion +{ + [self popToViewController:goToController andSwitchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeController andCompletion:completion]; +} + +- (void) popToController:(UIViewController *)goToController +andSwitchToViewController:(UIViewController *)viewController + withCompletion:(void (^)())completion +{ + [self popToViewController:goToController andSwitchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeController andCompletion:completion]; +} + - (void)closeMenuWithCompletion:(void (^)())completion { [self closeMenuWithDuration:self.menuRevealAnimationDuration andCompletion:completion]; From 47fc9eac5672129d340ca76b9e644b8c8945815f Mon Sep 17 00:00:00 2001 From: Burnie777 Date: Mon, 23 Oct 2017 10:42:25 +0200 Subject: [PATCH 2/5] commit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5517bc5..0f6000a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ iOS-Slide-Menu [![Version](http://cocoapod-badges.herokuapp.com/v/iOS-Slide-Menu/badge.png)](http://cocoadocs.org/docsets/iOS-Slide-Menu) --------- +// **NOTE: If your application supports both landscape and portrait and supports iOS versions below 8, use version 1.4.5** From 828cc146590e95a0fa7520c7e584888e2697e043 Mon Sep 17 00:00:00 2001 From: Burnie777 Date: Mon, 23 Oct 2017 10:43:39 +0200 Subject: [PATCH 3/5] commit2 --- License.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/License.txt b/License.txt index e9c1b0c..18179bd 100644 --- a/License.txt +++ b/License.txt @@ -19,4 +19,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. + +fasd \ No newline at end of file From b80edd4090b369acd29b4fa4e0566ee9fd9f8027 Mon Sep 17 00:00:00 2001 From: Burnie777 Date: Mon, 23 Oct 2017 10:56:12 +0200 Subject: [PATCH 4/5] Revert "commit2" This reverts commit 828cc146590e95a0fa7520c7e584888e2697e043. --- License.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/License.txt b/License.txt index 18179bd..e9c1b0c 100644 --- a/License.txt +++ b/License.txt @@ -19,6 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -fasd \ No newline at end of file +THE SOFTWARE. \ No newline at end of file From 62205b50f40c05868b3ac221eb5bcbb8c847f796 Mon Sep 17 00:00:00 2001 From: Burnie777 Date: Mon, 23 Oct 2017 10:56:27 +0200 Subject: [PATCH 5/5] Revert "commit" This reverts commit 47fc9eac5672129d340ca76b9e644b8c8945815f. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0f6000a..5517bc5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ iOS-Slide-Menu [![Version](http://cocoapod-badges.herokuapp.com/v/iOS-Slide-Menu/badge.png)](http://cocoadocs.org/docsets/iOS-Slide-Menu) --------- -// **NOTE: If your application supports both landscape and portrait and supports iOS versions below 8, use version 1.4.5**