You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On iPad, the device orientation state is not detected by OrientationStateTrigger. It works on iPhone, but not iPad, using the same iOS version (馃し).
I have also tried attaching IsActiveChanged - in the event handler I just log something to the console output. And verified that the event is not triggered on iPad (can also verify with a breakpoint).
Steps to Reproduce
Create a File | New | .NET MAUI app
Add a Style. Target anything, it doesn't matter
Add a Setter for VisualStateManager.VisualStateGroups
Add a VisualStateGroupList, and a VisualStateGroupLandscape and `Portrait1
In each group, add a VisualState, and in each state add a StateTrigger.
For each state trigger, add OrientationStateTrigger and set the Orientation respectively (e.g. Portrait and Landscape
Add a setter for each state to any property of the target type
Optionally, add an IsActiveChanged state trigger and an appropriate event handler
Apply the style to an element of the target type
Run the app on iPhone or Android (phone or tablet)
More info - I think this might be expected behaviour (if this is right, I think it needs to be documented). On iPadOS (which is different now from iOS), the orientation state is not triggered on device rotation, because iPad supports multitasking through split view and slideover and which means the orientation of the device many not reflect the orientation of the window.
I've seen some people mention a workaround by setting UIRequiresFullscreen to true in Info.plist, but this didn't work for me.
I did get a successful workaround by adding an event handler to SizeChanged. then I can compare height and width, or even get the orientation from DeviceDisplay.MainDisplayInfo.Orientation and then I can manually set the visual state (rather than using the trigger). This works well.
The DeviceDisplay.MainDisplayInfoChangeddoes fire when the device is rotated, but it does not fire when the app starts. So you could use this as the event to trigger layout changes, but you would need to set the initial state too. Simply using LayoutChanged or SizeChanged is probably simpler as these fire when the view is initialised, so can be used to set both your initial state and respond to orientation changes. This explains what I was seeing with OnOrientation extension.
You can see this approach in my repo on the test-set-fullscreen branch.
I'm not sure how people view this - I don't think this counts as a bug, but I do think this is something that needs to be mentioned in the documentation. I'll open a PR for the docs and write up some notes about this in a blog post in the meantime.
@matt-goldman yeah I agree. Thanks for uncovering this! I think a note in the official docs might be worth it here and then obviously feel free to write up a blog or something with more context and that people will find in the search results when hitting this.
If you're willing to open a PR (maybe first an issue?) on the docs repo that would be amazing!
Description
On iPad, the device orientation state is not detected by
OrientationStateTrigger
. It works on iPhone, but not iPad, using the same iOS version (馃し).I have also tried attaching
IsActiveChanged
- in the event handler I just log something to the console output. And verified that the event is not triggered on iPad (can also verify with a breakpoint).Steps to Reproduce
Style
. Target anything, it doesn't matterSetter
forVisualStateManager.VisualStateGroups
VisualStateGroupList
, and aVisualStateGroup
Landscape
and `Portrait1VisualState
, and in each state add aStateTrigger
.OrientationStateTrigger
and set theOrientation
respectively (e.g.Portrait
andLandscape
IsActiveChanged
state trigger and an appropriate event handlerLink to public reproduction project repository
https://github.com/matt-goldman/OrientationTest
Version with bug
8.0.6
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 17
Did you find any workaround?
I had some moderate success using the
OnOrientation
extension by @F-Goncalves (see: https://www.cayas.de/en/blog/responsive-layouts-for-dotnet-maui). But I can't get it working well, and it only works when the app launches in landscape. See branch onorientation-extension on the linked repo.Relevant log output
No response
The text was updated successfully, but these errors were encountered: