From a1fee4e41f0cfef95e4ddfba11d01a76c8cefc46 Mon Sep 17 00:00:00 2001 From: giomfo Date: Tue, 26 Apr 2016 09:49:48 +0200 Subject: [PATCH] Chat Screen: Keep visible the expanded header or the preview on screen rotation --- Vector/ViewController/RoomViewController.m | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index 9a27c9f1e..2f9abbea9 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -63,6 +63,8 @@ #import "VectorDesignValues.h" +#import "GBDeviceInfo_iOS.h" + @interface RoomViewController () { // The expanded header @@ -353,19 +355,27 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator { - // Hide expanded header on device rotation - [self showExpandedHeader:NO]; - - // Hide preview header (if any) during device rotation - BOOL isPreview = !self.previewScrollView.isHidden; - if (isPreview) + // Hide the expanded header or the preview in case of iPad and iPhone 6 plus. + // On these devices, the display mode of the splitviewcontroller may change during screen rotation. + // It may correspond to an overlay mode in portrait and a side-by-side mode in landscape. + // This display mode change involves a change at the navigation bar level. + // If we don't hide the header, the navigation bar is in a wrong state after rotation. FIXME: Find a way to keep visible the header on rotation. + if ([GBDeviceInfo deviceInfo].display == GBDeviceDisplayiPad || [GBDeviceInfo deviceInfo].display >= GBDeviceDisplayiPhone55Inch) { - [self showPreviewHeader:NO]; + // Hide expanded header on device rotation + [self showExpandedHeader:NO]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((coordinator.transitionDuration + 0.5) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // Hide preview header (if any) during device rotation + BOOL isPreview = !self.previewScrollView.isHidden; + if (isPreview) + { + [self showPreviewHeader:NO]; - [self showPreviewHeader:YES]; - }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((coordinator.transitionDuration + 0.5) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + + [self showPreviewHeader:YES]; + }); + } } [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];