Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance orientation handling in InteractivePreview and Preview classes
Summary: Improved the handling of orientation changes in the `InteractivePreview` and `Preview` classes to ensure proper resizing and layout adjustments of the `AVCaptureVideoPreviewLayer` during device rotation. These changes address issues where the preview layer would not correctly adapt to new geometry sizes, leading to misalignment. Details: 1. `InteractivePreview`: - Added an `onChange` modifier to observe changes in the geometry size. - Updated the `layer` frame on the main dispatch queue to ensure proper resizing. 2. `Preview`: - Removed the direct assignment of `previewLayer.frame` in `updateUIViewController`. - Ensured the `previewLayer` is added to the view controller’s layer only if it hasn’t been added already. - Updated the `previewLayer.frame` on the main dispatch queue to ensure it resizes correctly when the view bounds change. NOTE: This will not affect the orientation of the session. To do that, application code must wrap the preview layer with handlers that call `aespaSession.common(.orientation(orientation: ...))`. I have some code that demonstrates this, but it's very specific to my app, so I couldn't cleanly extract a good example for the README. I can try to tackle that in a future commit.
- Loading branch information
bde72fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @subelsky I am facing a couple of orientation issues in my app (see #54 and #55). I now saw your comment about the orientation of the session. Could you maybe share how the orientation has to be handled by the surrounding view? Maybe this will help in my case. (I even implemented logic that auto-rotates images based off gyroscope data, but then realized that Aespa behaves differently on iPads as well).
bde72fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing! this is omitting some unrelated details, and probably not how I would design it from scratch, but it roughly evolved to look like this:
bde72fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!