Skip to content

Commit

Permalink
Fix size of media on iPad when multitasking.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jun 24, 2022
1 parent 177d77b commit 730eafc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#import "MXKSwiftHeader.h"

#import "LegacyAppDelegate.h"

@interface MXKAttachmentsViewController () <UINavigationControllerDelegate, UIViewControllerTransitioningDelegate>
{
/**
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-6339.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Media: Fix size issues when opening media on an iPad whilst multi-tasking.

0 comments on commit 730eafc

Please sign in to comment.