Bläddra i källkod

iOS: Fix orientation issue when switching views

Adds orientation checking when the view is appearing.
Furthermore, the orientation checking is now done by using size classes for iOS 8.0 and later.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Soomin Lee 8 år sedan
förälder
incheckning
922c995d94
1 ändrade filer med 10 tillägg och 4 borttagningar
  1. 10 4
      Sources/VLCLibraryViewController.m

+ 10 - 4
Sources/VLCLibraryViewController.m

@@ -255,7 +255,8 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 {
     [super viewWillAppear:animated];
     [self.collectionView.collectionViewLayout invalidateLayout];
-    [self _displayEmptyLibraryViewIfNeeded];
+    [self setViewFromDeviceOrientation];
+    [self updateViewsForCurrentDisplayMode];
     [self enableNavigationBarAnimation:YES resetPositionWithAnimation:YES];
 }
 
@@ -495,10 +496,15 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 - (void)setViewFromDeviceOrientation
 {
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
-        UIDevice *currentDevice = [UIDevice currentDevice];
-        UIDeviceOrientation orientation = currentDevice.orientation;
+        BOOL isPortrait = YES;
 
-        BOOL isPortrait = (orientation == UIDeviceOrientationUnknown) ? self.usingTableViewToShowData : UIDeviceOrientationIsPortrait(orientation);
+        if (SYSTEM_RUNS_IOS8_OR_LATER) {
+            if (self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact)
+                isPortrait = NO;
+        } else {
+            if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
+                isPortrait = NO;
+        }
 
         if (self.isEditing) {
             [self setEditing:NO animated:NO];