Browse Source

iOS: Add iOS 8 rotation method

Add to VLCLibraryViewController and VLCMovieViewController non deprecated method for handling rotation

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Soomin Lee 8 years ago
parent
commit
f2af43ed49
2 changed files with 38 additions and 7 deletions
  1. 13 1
      Sources/VLCLibraryViewController.m
  2. 25 6
      Sources/VLCMovieViewController.m

+ 13 - 1
Sources/VLCLibraryViewController.m

@@ -1706,7 +1706,6 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {
     [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
-
     [self setViewFromDeviceOrientation];
     if (self.usingTableViewToShowData) {
         NSArray *visibleCells = [self.tableView visibleCells];
@@ -1720,6 +1719,19 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     }
 }
 
+// >= iOS 8
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
+{
+    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+
+    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
+        [self setViewFromDeviceOrientation];
+        if (!self.usingTableViewToShowData) {
+            [self.collectionView.collectionViewLayout invalidateLayout];
+        }
+    } completion:nil];
+}
+
 #pragma mark - Search Display Controller Delegate
 
 - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString

+ 25 - 6
Sources/VLCMovieViewController.m

@@ -1748,22 +1748,41 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
            || toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
 }
 
+// < iOS 8
 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {
     [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+    if (self.artworkImageView.image)
+        self.trackNameLabel.hidden = UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
+
+    if (!_equalizerView.hidden)
+        _equalizerView.hidden = YES;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+{
+    if (_vpc.activePlaybackSession && _controlsHidden)
+        [self setControlsHidden:NO animated:YES];
+}
+
+// >= iOS 8
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
+{
+    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
 
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
 
-        [[(VLCAppDelegate *)[UIApplication sharedApplication].delegate libraryViewController] willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
-        if (self.artworkImageView.image)
-            self.trackNameLabel.hidden = UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
+        [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
+                if (self.artworkImageView.image)
+                    self.trackNameLabel.hidden = YES;
 
-        if (!_equalizerView.hidden)
-            _equalizerView.hidden = YES;
+                if (!_equalizerView.hidden)
+                    _equalizerView.hidden = YES;
+        } completion:nil];
     }
 }
 
-- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
 {
     if (_vpc.activePlaybackSession && _controlsHidden)
         [self setControlsHidden:NO animated:YES];