Skip to content

Commit

Permalink
Merge pull request #75 from aryaxt/iOS8-Compatability
Browse files Browse the repository at this point in the history
iOS 8 fixes including bug #66
  • Loading branch information
aryaxt committed Oct 1, 2014
2 parents 8137873 + ffa26fb commit 5aa1fbc
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 145 deletions.
179 changes: 100 additions & 79 deletions SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ @implementation SlideNavigationContorllerAnimatorSlide

- (id)init
{
if (self = [self initWithSlideMovement:100])
{
}
return self;
if (self = [self initWithSlideMovement:100])
{
}
return self;
}

- (id)initWithSlideMovement:(CGFloat)slideMovement
Expand All @@ -55,98 +55,119 @@ - (id)initWithSlideMovement:(CGFloat)slideMovement
- (void)prepareMenuForAnimation:(Menu)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;
CGRect rect = menuViewController.view.frame;

if (UIInterfaceOrientationIsLandscape(orientation))
{
if (orientation == UIInterfaceOrientationLandscapeRight)
{
rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.y = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
}
}
else
{
if (orientation == UIInterfaceOrientationPortrait)
{
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.x = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
}
}

menuViewController.view.frame = rect;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
rect.origin.x = self.slideMovement;
}
else
{
if (UIInterfaceOrientationIsLandscape(orientation))
{
if (orientation == UIInterfaceOrientationLandscapeRight)
{
rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.y = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
}
}
else
{
if (orientation == UIInterfaceOrientationPortrait)
{
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.x = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
}
}
}

menuViewController.view.frame = rect;
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
{
UIViewController *menuViewController = (menu == MenuLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;

NSInteger location = (menu == MenuLeft)
? (self.slideMovement * -1) + (self.slideMovement * progress)
: (self.slideMovement * (1-progress));

if (menu == MenuLeft)
location = (location > 0) ? 0 : location;

if (menu == MenuRight)
location = (location < 0) ? 0 : location;

CGRect rect = menuViewController.view.frame;

if (UIInterfaceOrientationIsLandscape(orientation))
{
rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1;
}
else
{
rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1;
}

menuViewController.view.frame = rect;
UIViewController *menuViewController = (menu == MenuLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIInterfaceOrientation orientation = [SlideNavigationController sharedInstance].interfaceOrientation;

NSInteger location = (menu == MenuLeft)
? (self.slideMovement * -1) + (self.slideMovement * progress)
: (self.slideMovement * (1-progress));

if (menu == MenuLeft)
location = (location > 0) ? 0 : location;

if (menu == MenuRight)
location = (location < 0) ? 0 : location;

CGRect rect = menuViewController.view.frame;

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
rect.origin.x = location;
}
else
{
if (UIInterfaceOrientationIsLandscape(orientation))
{
rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1;
}
else
{
rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1;
}
}

menuViewController.view.frame = rect;
}

- (void)clear
{
[self clearMenu:MenuLeft];
[self clearMenu:MenuRight];
[self clearMenu:MenuLeft];
[self clearMenu:MenuRight];
}

#pragma mark - Private Method -

- (void)clearMenu:(Menu)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;

CGRect rect = menuViewController.view.frame;

if (UIInterfaceOrientationIsLandscape(orientation))
{
rect.origin.y = 0;
}
else
{
rect.origin.x = 0;
}

menuViewController.view.frame = rect;
UIViewController *menuViewController = (menu == MenuLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;

CGRect rect = menuViewController.view.frame;

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
rect.origin.x = 0;
}
else
{
if (UIInterfaceOrientationIsLandscape(orientation))
{
rect.origin.y = 0;
}
else
{
rect.origin.x = 0;
}
}

menuViewController.view.frame = rect;
}

@end
2 changes: 2 additions & 0 deletions SlideMenu/Source/SlideNavigationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

@protocol SlideNavigationControllerDelegate <NSObject>
@optional
- (BOOL)slideNavigationControllerShouldDisplayRightMenu;
Expand Down
Loading

0 comments on commit 5aa1fbc

Please sign in to comment.