Skip to content

Loading…

status bar use instead of device use #1

Merged
merged 1 commit into from

2 participants

@williampower

...cases where a view may be forced into an orientation (which means the device orientation and status bar orientation won't match)

There are device orientations that will be omitted, but this addresses the case where the view was forced to an orientation that differs from the device orientation.

@williampower williampower updated to use status bar orientation instead of device orientation f…
…or cases where a view may be forced into an orientation (which means the device orientation and status bar orientation won't match)
4a539fa
@JeremyOT JeremyOT merged commit 8080ac3 into JeremyOT:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 16, 2012
  1. @williampower

    updated to use status bar orientation instead of device orientation f…

    williampower committed
    …or cases where a view may be forced into an orientation (which means the device orientation and status bar orientation won't match)
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 3 deletions.
  1. +1 −0 SlideMenu/TrayView.h
  2. +7 −3 SlideMenu/TrayView.m
View
1 SlideMenu/TrayView.h
@@ -22,6 +22,7 @@ typedef enum {
@property (nonatomic, retain) UIImage *backgroundImage;
@property (nonatomic, assign) TrayPosition trayPosition;
@property (nonatomic) BOOL tapOffToClose;
+@property (nonatomic) BOOL autoHideOnRotate;
@property (nonatomic) NSTimeInterval defaultAnimationDuration;
@property (nonatomic, copy) void (^closedBlock)();
@property (nonatomic, copy) void (^bouncedBlock)();
View
10 SlideMenu/TrayView.m
@@ -25,6 +25,7 @@ @implementation TrayView
@synthesize bouncedBlock = _bouncedBlock;
@synthesize tapOffToClose = _tapOffToClose;
@synthesize trayCloseRecognizerView = _trayCloseRecognizerView;
+@synthesize autoHideOnRotate=_autoHideOnRotate;
#pragma mark - Lifecycle
@@ -46,8 +47,8 @@ - (id)initWithFrame:(CGRect)frame {
_orientation = [[UIApplication sharedApplication] statusBarOrientation];
_defaultAnimationDuration = 0.25;
_tapOffToClose = YES;
- [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
+ _autoHideOnRotate = YES;
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
return self;
}
@@ -292,7 +293,7 @@ -(void)setUIInterfaceOrientation:(UIInterfaceOrientation)orientation supported:(
}
-(void)orientationDidChange:(NSNotification*)note {
- UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == _orientation || !_supportedOrientations[orientation]) {
return;
}
@@ -303,6 +304,9 @@ -(void)orientationDidChange:(NSNotification*)note {
} completion:^(BOOL finished) {
self.alpha = 1;
}];
+ if(_autoHideOnRotate){
+ [self hide];
+ }
}
_orientation = orientation;
}
Something went wrong with that request. Please try again.