diff --git a/src/AGPhotoBrowserCell.m b/src/AGPhotoBrowserCell.m index bb7f804..59f7d65 100644 --- a/src/AGPhotoBrowserCell.m +++ b/src/AGPhotoBrowserCell.m @@ -51,15 +51,15 @@ - (void)setFrame:(CGRect)frame // -- Force the right frame CGRect correctFrame = frame; UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; - if (UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation)) { - if (UIDeviceOrientationIsPortrait(orientation)) { - correctFrame.size.width = CGRectGetHeight([[UIScreen mainScreen] bounds]); - correctFrame.size.height = CGRectGetWidth([[UIScreen mainScreen] bounds]); - } else { - correctFrame.size.width = CGRectGetWidth([[UIScreen mainScreen] bounds]); - correctFrame.size.height = CGRectGetHeight([[UIScreen mainScreen] bounds]); - } - } + if (UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation) || orientation == UIDeviceOrientationFaceUp) { + if (UIDeviceOrientationIsPortrait(orientation) || orientation == UIDeviceOrientationFaceUp) { + correctFrame.size.width = CGRectGetHeight([[UIScreen mainScreen] bounds]); + correctFrame.size.height = CGRectGetWidth([[UIScreen mainScreen] bounds]); + } else { + correctFrame.size.width = CGRectGetWidth([[UIScreen mainScreen] bounds]); + correctFrame.size.height = CGRectGetHeight([[UIScreen mainScreen] bounds]); + } + } [super setFrame:correctFrame]; } diff --git a/src/AGPhotoBrowserView.m b/src/AGPhotoBrowserView.m index e3070b4..f93edcd 100644 --- a/src/AGPhotoBrowserView.m +++ b/src/AGPhotoBrowserView.m @@ -143,7 +143,6 @@ - (AGPhotoBrowserOverlayView *)overlayView - (CGFloat)cellHeight { - //UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; if (UIDeviceOrientationIsLandscape(orientation)) { return CGRectGetHeight(self.currentWindow.frame); @@ -391,7 +390,7 @@ - (void)p_imageViewPanned:(UIPanGestureRecognizer *)recognizer UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; CGPoint translatedPoint; - if (UIDeviceOrientationIsPortrait(orientation)) { + if (UIDeviceOrientationIsPortrait(orientation) || orientation == UIDeviceOrientationFaceUp) { translatedPoint = CGPointMake(_startingPanPoint.x - endingPanPoint.y, _startingPanPoint.y); } else if (orientation == UIDeviceOrientationLandscapeLeft) { translatedPoint = CGPointMake(_startingPanPoint.x + endingPanPoint.x, _startingPanPoint.y); @@ -403,7 +402,6 @@ - (void)p_imageViewPanned:(UIPanGestureRecognizer *)recognizer int heightDifference = abs(floor(_startingPanPoint.x - translatedPoint.x)); if (heightDifference <= AGPhotoBrowserThresholdToCenter) { - // -- Back to original center [UIView animateWithDuration:AGPhotoBrowserAnimationDuration animations:^(){ @@ -429,7 +427,7 @@ - (void)p_imageViewPanned:(UIPanGestureRecognizer *)recognizer UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; CGPoint translatedPoint; - if (UIDeviceOrientationIsPortrait(orientation)) { + if (UIDeviceOrientationIsPortrait(orientation) || orientation == UIDeviceOrientationFaceUp) { translatedPoint = CGPointMake(_startingPanPoint.x - middlePanPoint.y, _startingPanPoint.y); } else if (orientation == UIDeviceOrientationLandscapeLeft) { translatedPoint = CGPointMake(_startingPanPoint.x + middlePanPoint.x, _startingPanPoint.y); @@ -462,7 +460,7 @@ - (void)statusBarDidChangeFrame:(NSNotification *)notification { // -- Get the device orientation UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; - if (UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation)) { + if (UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation) || orientation == UIDeviceOrientationFaceUp) { _changingOrientation = YES; CGFloat angleTable = UIInterfaceOrientationAngleOfOrientation(orientation); @@ -477,7 +475,7 @@ - (void)statusBarDidChangeFrame:(NSNotification *)notification // -- Update table [self setTransform:tableTransform andFrame:tableFrame forView:self.photoTableView]; - if (UIDeviceOrientationIsPortrait(orientation)) { + if (UIDeviceOrientationIsPortrait(orientation) || orientation == UIDeviceOrientationFaceUp) { overlayFrame = CGRectMake(0, CGRectGetHeight(tableFrame) - AGPhotoBrowserOverlayInitialHeight, CGRectGetWidth(tableFrame), AGPhotoBrowserOverlayInitialHeight); doneFrame = CGRectMake(CGRectGetWidth(tableFrame) - 60 - 10, 15, 60, 32); } else if (orientation == UIDeviceOrientationLandscapeLeft) {