Share via

Carouselview doesnt update when changing device orientatoin on IOS

Carolous Ghobrial 1 Reputation point
2021-04-19T15:39:28.213+00:00

The CarouselView doesn't relayout when changing the device orientation.

Steps to Reproduce
Run Project
Tilt your Device to landscape/portrait mode
Expected Behavior
The View should adjust to the new heights/widths, like on Android.

Actual Behavior
The View doesn't relayout. Some parts become invisible or look

Developer technologies | .NET | Xamarin
0 comments No comments

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2021-04-20T06:28:12.327+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Normally there are two ways to solve the problem .

    • We use regular layout(e.g StackLayout, Grid) and detect the device rotation with OnSizeAllocated method in Forms , adjust the UI based on the orientation of the device. protected override void OnSizeAllocated (double width, double height){
      base.OnSizeAllocated (width, height);
      if (width != this.width || height != this.height) {
      this.width = width;
      this.height = height;
      if (width > height) {
      //adjust ui
      } else {
      //adjust ui
      }
      }
      }
      • Use RelativeLayout directly , in this way there is no need for procedural code to introduce responsiveness.

    Refer to https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/device-orientation?tabs=windows.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.