소스 검색

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