Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPhotoBrowser not rotating correctly on iPhone X #637

Open
cstm opened this issue Jun 13, 2018 · 2 comments
Open

MWPhotoBrowser not rotating correctly on iPhone X #637

cstm opened this issue Jun 13, 2018 · 2 comments

Comments

@cstm
Copy link

cstm commented Jun 13, 2018

When i try to rotate on an image, it shows up a new image
It seems to happen only on iPhone X
Is there any workaround for this ?

@cstm cstm changed the title MWPhotoBrowser not rotating correcly on iPhone X MWPhotoBrowser not rotating correctly on iPhone X Jun 13, 2018
@foolsparadise
Copy link

这一块代码,在commit 66ddd73-on Apr 22, 2016基础上添加的,使用工程中的Library photos and videos一块,UI在iPhoneX上我这边试了下是OK了,其它建议类推。希望能帮到你。
Library photos and videos UI in this project , checked Run OK in iPhoneX , code based on commit 66ddd73-on Apr 22, 2016 , maybe help you

diff --git a/Pod/Classes/MWPhotoBrowser.m b/Pod/Classes/MWPhotoBrowser.m
index 0de7faa..80dcf8d 100644
--- a/Pod/Classes/MWPhotoBrowser.m
+++ b/Pod/Classes/MWPhotoBrowser.m
@@ -15,6 +15,12 @@
 
 #define PADDING                  10
 
+#define IOS11_OR_LATER_SPACE(par) ({ float space = 0.0; if ([[UIDevice currentDevice] systemVersion].floatValue>=11) { space = par; } (space); })
+#define JF_KEY_WINDOW [UIApplication sharedApplication].keyWindow
+#define JF_TOP_SPACE IOS11_OR_LATER_SPACE(JF_KEY_WINDOW.safeAreaInsets.top)
+#define JF_TOP_ACTIVE_SPACE IOS11_OR_LATER_SPACE(MAX(0, JF_KEY_WINDOW.safeAreaInsets.top-20))
+#define JF_BOTTOM_SPACE IOS11_OR_LATER_SPACE(JF_KEY_WINDOW.safeAreaInsets.bottom)
+
 static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
 
 @implementation MWPhotoBrowser
@@ -161,6 +167,9 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
        
     // Toolbar
     _toolbar = [[UIToolbar alloc] initWithFrame:[self frameForToolbarAtOrientation:self.interfaceOrientation]];
+    CGRect frame = _toolbar.frame;
+    frame.origin.y = self.view.bounds.size.height - frame.size.height - JF_BOTTOM_SPACE;
+    _toolbar.frame = frame;
     _toolbar.tintColor = [UIColor whiteColor];
     _toolbar.barTintColor = nil;
     [_toolbar setBackgroundImage:nil forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
@@ -283,6 +292,9 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
         [_toolbar removeFromSuperview];
     } else {
         [self.view addSubview:_toolbar];
+        CGRect frame = _toolbar.frame;
+        frame.origin.y = self.view.bounds.size.height - frame.size.height - JF_BOTTOM_SPACE;
+        _toolbar.frame = frame;
     }
     
     // Update nav
@@ -495,7 +507,9 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
        
        // Toolbar
        _toolbar.frame = [self frameForToolbarAtOrientation:self.interfaceOrientation];
-    
+    CGRect frame = _toolbar.frame;
+    frame.origin.y = self.view.bounds.size.height - frame.size.height - JF_BOTTOM_SPACE;
+    _toolbar.frame = frame;
        // Remember index
        NSUInteger indexPriorToLayout = _currentPageIndex;
        
@@ -1438,7 +1452,9 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
         
         // Toolbar
         _toolbar.frame = CGRectOffset([self frameForToolbarAtOrientation:self.interfaceOrientation], 0, animatonOffset);
-        
+        CGRect frame = _toolbar.frame;
+        frame.origin.y = self.view.bounds.size.height - frame.size.height - JF_BOTTOM_SPACE;
+        _toolbar.frame = frame;
         // Captions
         for (MWZoomingScrollView *page in _visiblePages) {
             if (page.captionView) {
@@ -1461,6 +1477,9 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
         // Toolbar
         _toolbar.frame = [self frameForToolbarAtOrientation:self.interfaceOrientation];
         if (hidden) _toolbar.frame = CGRectOffset(_toolbar.frame, 0, animatonOffset);
+        CGRect frame = _toolbar.frame;
+        frame.origin.y = self.view.bounds.size.height - frame.size.height - JF_BOTTOM_SPACE;
+        _toolbar.frame = frame;
         _toolbar.alpha = alpha;
 
         // Captions

@cstm
Copy link
Author

cstm commented Jun 22, 2018

this will not fix the issue.
We you rotate an image for exemple 5/50, i will show an other image like 12/50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants