Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves the following issue that occurs when displaying Popup on iPhone 11 or lower, iPhone Plus, and iPhone Pro Max.
The exception is occurring at the location below, but it is not caused by the SetShadowView method.
[src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs]
Description of Change
Below is the solution.
The newly added code is the two lines above.
Resolving the Null reference exception in the SetSahdowView method causes the popup to display in modal form sheet style when the device orientation is landscape. To solve the problem, I focused on its behavior.
When I investigated the behavior for each device, we found that iPhone 11 or lower, iPhone Plue, and iPhone Pro Max exhibit this behavior. On devices other than those listed above, the Popup was displayed as intended, and on the devices listed above, the Popup was not displayed.
I was looking for a case where it is displayed in a modal form sheet format when the device is in landscape orientation.
I found the post below.
https://developer.apple.com/forums/thread/71350
https://stackoverflow.com/questions/30378249/uimodalpresentationpopover-for-iphone-6-plus-in-landscape-doesnt-display-popove
According to the above post, you need to override the method below and explicitly return UIModalPresentationStyle.none as the return value.
The same method as above is shown below.
On the device where the problem occurs, you need to override the above method and return UIModalPresentationStyle.None as the return value.
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
Below are the verification results.
[iPhone 11]
iPhone11.iOS.14.5.iOS.14.5.2024-05-17.10-17-50.mp4
iPhone11.iOS.14.5.iOS.14.5.2024-05-17.10-18-07.mp4
[iPhone 15 Plus]
iPhone.15.Plus.iOS.17.0.2024-05-17.10-07-33.mp4
iPhone.15.Plus.iOS.17.0.2024-05-17.10-07-52.mp4
[iPhone 15 Pro Max]
iPhone.15.Pro.Max.iOS.17.0.2024-05-17.10-13-42.mp4
iPhone.15.Pro.Max.iOS.17.0.2024-05-17.10-14-01.mp4
[iPhone 15]
iPhone.15.iOS.17.0.2024-05-17.10-02-45.mp4
iPhone.15.iOS.17.0.2024-05-17.10-03-03.mp4
You can see that the crash does not occur even if you rotate the orientation of the device while viewing the Popup.
You'll notice that if your device is in landscape orientation, it won't crash when you display the popup.