浏览代码

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];