Skip to content
Merged
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
8 changes: 7 additions & 1 deletion Objective-C/TOCropViewController/TOCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,18 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
// If the size doesn't change (e.g, we did a 180 degree device rotation), don't bother doing a relayout
if (CGSizeEqualToSize(size, self.view.bounds.size)) { return; }

#if !TARGET_OS_VISION
UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait;
CGSize currentSize = self.view.bounds.size;
if (currentSize.width < size.width) {
orientation = UIInterfaceOrientationLandscapeLeft;
}

#else
// On visionOS, this method is called on presentation with size=(0,0),
// which would set orientation incorrectly causing views to be misplaced.
UIInterfaceOrientation orientation = UIInterfaceOrientationLandscapeLeft;
#endif

[self _willRotateToInterfaceOrientation:orientation duration:coordinator.transitionDuration];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self _willAnimateRotationToInterfaceOrientation:orientation duration:coordinator.transitionDuration];
Expand Down