ListView HasUnevenRows not working on iOS - cell height is incorrect

Alex_DarbyAlex_Darby USMember
edited December 2016 in Xamarin.Forms

I have a ListView with a collection of ViewCells. When scrolling to a list item the cell render height is incorrect on iOS so it cuts off some of the contents at the bottom of the ViewCell.

If I scroll the view cell off the screen and then back on the screen the view cell height becomes correct and all the view cell contents are displayed correctly.

Has anyone come up with a solution for this? This works perfectly on Android.

I have tried everything that has been mentioned on the forums but nothing is working.

I have the latest Xamarin both Android and iOS versions (released yesterday).

Posts

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    Most probably you set the Height of the Cell too late. It has to be set very early to work on iOS. If you update the Height too late, it won't be changed anymore.

  • Alex_DarbyAlex_Darby USMember

    @MichaelRumpler said:
    Most probably you set the Height of the Cell too late. It has to be set very early to work on iOS. If you update the Height too late, it won't be changed anymore.

    I do not set the height of the cell anywhere.

    I have dynamic content in the cell (image url) so there is no way of knowing the exact height needed for a cell.

    The cell height is something that Xamarin forms should be taking care off like in the Android version?

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    They don't do everything they should do and unfortunately they often think that they should do different things than we think.

    However, you have to set the Height of the cell yourself. It will not be measured for you. And you have to measure the height before Xamarin.Forms renders it or it will be too late to set Height.

    Search the forum, there are already plenty of posts discussing this problem.

  • Alex_DarbyAlex_Darby USMember
    edited December 2016

    @MichaelRumpler said:
    They don't do everything they should do and unfortunately they often think that they should do different things than we think.

    However, you have to set the Height of the cell yourself. It will not be measured for you. And you have to measure the height before Xamarin.Forms renders it or it will be too late to set Height.

    Search the forum, there are already plenty of posts discussing this problem.

    Yes but if you have a image url being downloaded and displayed at the bottom of the view cell there is no way of knowing what the row height should be due to the image size.

    Unless there is a easy way to check when the image has finished downloading and displaying and the view cell contents can be checked for the combined height to set for the view cell.

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    You could download the image yourself, check the image height, set the cell height and then use a StreamImageSource to display it.

  • Alex_DarbyAlex_Darby USMember
    edited December 2016

    @MichaelRumpler said:
    You could download the image yourself, check the image height, set the cell height and then use a StreamImageSource to display it.

    It all sound very messy really as there will be other people having problems with setting the view cell height on iOS with different dynamic content.

    This really needs a proper solution put into place by Xamarin.

    Thanks for your input.

  • Alex_DarbyAlex_Darby USMember
    edited December 2016

    I got around the issue by setting a value for the cell image HeightRequest so now the cell contents are wrapped correctly.

    This is a compromise though as now the images are reduced on the vertical dimension and there is now additional space above and below the image element if the source image height is below the HeightRequest value.

    I have seen a lot of posts of people talking about iOS cell heights causing issues if the cell contents are changed after the initial cell height calculations so hopefully Xamarin can soon provide a robust solution to this problem.

  • ReubenTurkReubenTurk USMember
    edited March 2017

    Unfortunately it seems that HasUnevenRows just doesn't work on iOS currently.
    The image height issue didn't help for me, since I also have variable length text in my list items, which is sometimes taller than the image.

    I even have the same cells loading at different heights on subsequent loads.

    [EDIT]
    Removing CachingStrategy="RecycleElement" seems to fix it for me on iOS.

  • Alex_DarbyAlex_Darby USMember

    @ReubenTurk said:
    Unfortunately it seems that HasUnevenRows just doesn't work on iOS currently.
    The image height issue didn't help for me, since I also have variable length text in my list items, which is sometimes taller than the image.

    I even have the same cells loading at different heights on subsequent loads.

    [EDIT]
    Removing CachingStrategy="RecycleElement" seems to fix it for me on iOS.

    Text height has always worked correctly for me on initial view list creation (not tried dynamic view cell text changes).

    I tried changing the CachingStrategy to the default value for my image problem issue but that caused new issues and also had a pretty big performance impact.

Sign In or Register to comment.