diff --git a/Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.h b/Riot/Modules/Room/Attachements/MXKAttachmentsViewController.h similarity index 100% rename from Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.h rename to Riot/Modules/Room/Attachements/MXKAttachmentsViewController.h diff --git a/Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.m b/Riot/Modules/Room/Attachements/MXKAttachmentsViewController.m similarity index 98% rename from Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.m rename to Riot/Modules/Room/Attachements/MXKAttachmentsViewController.m index 721b9e08bc..6633ce7b37 100644 --- a/Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.m +++ b/Riot/Modules/Room/Attachements/MXKAttachmentsViewController.m @@ -38,6 +38,8 @@ #import "MXKSwiftHeader.h" +#import "LegacyAppDelegate.h" + @interface MXKAttachmentsViewController () { /** @@ -472,7 +474,9 @@ - (void)refreshCurrentVisibleItemIndex // Check whether the collection is actually rendered if (_attachmentsCollection.contentSize.width) { - currentVisibleItemIndex = _attachmentsCollection.contentOffset.x / [[UIScreen mainScreen] bounds].size.width; + // Get the window from the app delegate as this can be called before the view is presented. + UIWindow *window = LegacyAppDelegate.theDelegate.window; + currentVisibleItemIndex = _attachmentsCollection.contentOffset.x / window.bounds.size.width; } else { @@ -484,9 +488,12 @@ - (void)refreshAttachmentCollectionContentOffset { if (currentVisibleItemIndex != NSNotFound && _attachmentsCollection) { + // Get the window from the app delegate as this can be called before the view is presented. + UIWindow *window = LegacyAppDelegate.theDelegate.window; + // Set the content offset to display the current attachment CGPoint contentOffset = _attachmentsCollection.contentOffset; - contentOffset.x = currentVisibleItemIndex * [[UIScreen mainScreen] bounds].size.width; + contentOffset.x = currentVisibleItemIndex * window.bounds.size.width; _attachmentsCollection.contentOffset = contentOffset; } } @@ -1118,7 +1125,8 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - return [[UIScreen mainScreen] bounds].size; + // Use the window from the app delegate as this can be called before the view is presented. + return LegacyAppDelegate.theDelegate.window.bounds.size; } #pragma mark - Movie Player diff --git a/Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.xib b/Riot/Modules/Room/Attachements/MXKAttachmentsViewController.xib similarity index 100% rename from Riot/Modules/MatrixKit/Controllers/MXKAttachmentsViewController.xib rename to Riot/Modules/Room/Attachements/MXKAttachmentsViewController.xib diff --git a/changelog.d/pr-6339.bugfix b/changelog.d/pr-6339.bugfix new file mode 100644 index 0000000000..9a79090dfa --- /dev/null +++ b/changelog.d/pr-6339.bugfix @@ -0,0 +1 @@ +Media: Fix size issues when opening media on an iPad whilst multi-tasking. \ No newline at end of file