Преглед на файлове

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 години
родител
ревизия
922c995d94
променени са 1 файла, в които са добавени 10 реда и са изтрити 4 реда
  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];