Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix size of media on iPad when multitasking. #6339

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.