Bug 34055 - Listview with custom CellView render error on iOS9 landscape iPad
Summary: Listview with custom CellView render error on iOS9 landscape iPad
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.0
Hardware: Other Other
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-09-18 07:19 UTC by RogerH
Modified: 2016-04-13 17:11 UTC (History)
13 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
screen shot of bug (10.28 KB, image/png)
2015-09-18 07:19 UTC, RogerH
Details
Screenshot of bug behavior (113.76 KB, image/png)
2015-09-21 02:42 UTC, Gerald Versluis
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description RogerH 2015-09-18 07:19:29 UTC
Created attachment 12944 [details]
screen shot of bug

Existing Xamarin Forms code with a Listview and a Custom ViewCall now fails to render correctly with iOS9 and Xcode 7
This appears on iPads with iOS9

With iOS8 and Xcode 6 the Listview looked like this.

 ITEM 1
 -----------------
 ITEM 2
 -----------------
 ITEM 3
 -----------------

With iOS9 on iPad with Xcode 7 the Listview now looks like this (see screen shot)

 ITEM 1
           -----------
 ITEM 2
           -----------
 ITEM 3
           -----------


The code below is a complete sample that shows the bug.
It is confirmed by another Xamarin Forms user on the Forum




    using System;

    using Xamarin.Forms;

    namespace ListViewBug2
    {
        public class App : Application
        {
            public App ()
            {

                ListView listview = new ListView();
                listview.ItemsSource = new String[]{"one","two","three"};
                listview.ItemTemplate = new DataTemplate(typeof (CustomCell));


                // The root page of your application
                MainPage = new ContentPage {
                    Content = new StackLayout {
                        VerticalOptions = LayoutOptions.Center,
                        Children = {
                            new Label {
                                XAlign = TextAlignment.Center,
                                Text = "Welcome to Xamarin Forms!"
                            },
                            listview,
                        },
                        Padding = new Thickness(0,20,0,0),
                    }
                };
            }

        }

        public class CustomCell : ViewCell {
            // Constructor
            public CustomCell() {
                Label myLabel = new Label();
                myLabel.Text = "custom list item";  // Hard code for now
                View = myLabel;
            }
        }
    }
Comment 1 Paul DiPietro [MSFT] 2015-09-18 12:49:16 UTC
This is applicable to the current 1.5.0.6446 release as well as the latest 1.4.4 version (and presumably anything prior as it's iOS9 related).
Comment 2 Gerald Versluis 2015-09-21 02:42:24 UTC
Created attachment 12986 [details]
Screenshot of bug behavior

I've also attached a screenshot of the behavior of this bug.
As you can see it is not only the separators, but also the header text is indented.
Comment 3 NMackay 2015-09-21 06:28:34 UTC
Hi,

Can confirm this bug too.

iPad Air 2 Sim
Forms 1.5.0

Xamarin   3.11.1443.0 (39031d3)
Xamarin.Android   5.1.6.7 (58099c5358da3488b0e7fb0bb4af47aca7cc61d6)
Xamarin.iOS   9.0.1.0 (7eaf3bc2053ad0d4f720422bb3dc13504d61f7b5)
Comment 4 Greg Shackles 2015-09-24 20:09:12 UTC
I'm seeing this same behavior in a regular Xamarin.iOS project, so it doesn't seem limited to Forms apps
Comment 5 Chris 2015-10-07 07:47:15 UTC
Hi, 
 I have the same issue described above BUT I deployed our app to the apple AppStore to test it on real device via Testflight. After installing the app the described issue is gone. So it seems to be a problem in the simulator or direct deploy to a device or Apple is doing some modifications inside the code!?
Comment 6 Rohit 2015-11-09 10:25:28 UTC
Hi

I am still facing this issue on XamrinForms version 1.5.0.6447.

Do we have any timeline when this issue will be resolved?

Thanks !
Comment 7 Gerald Versluis 2015-11-09 10:57:53 UTC
Hi Rohit,

Meanwhile, you can use this workaround:

using FormulierenApp.iOS.CustomRenderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using ListViewRenderer = CustomRenderers.ListViewRenderer;

[assembly: ExportRenderer(typeof(ListView), typeof(ListViewRenderer))]
[assembly: ExportRenderer(typeof(TableView), typeof(UITableViewRenderer))]

// [HACK]: Needed because of a bug in Xamarin
namespace CustomRenderers
{
    public class ListViewRenderer : Xamarin.Forms.Platform.iOS.ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
                return;

            var tableView = Control as UITableView;

            tableView.CellLayoutMarginsFollowReadableWidth = false;
        }
    }

    public class UITableViewRenderer : Xamarin.Forms.Platform.iOS.TableViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
                return;

            var tableView = Control as UITableView;

            tableView.CellLayoutMarginsFollowReadableWidth = false;
        }
    }
}
Comment 8 Rohit 2015-11-09 11:02:43 UTC
Thanks Gerald.

Yes  Renderer approach works perfectly i tried last week.  I was checking timeline to fix from xamarin so that i dont have to enable and disable use of renderer  for listview through out the app.

Thanks once again.
Comment 9 Rohit 2016-01-05 21:06:40 UTC
Hi Support, can we have any update on fix for this issue. Or Xamarin want all the listview should use custom render to fix the issue.

Thanks !
Comment 10 Jason Smith [MSFT] 2016-03-11 09:08:11 UTC
We're looking into it now
Comment 11 Jason Smith [MSFT] 2016-03-11 09:19:22 UTC
Should be fixed in 2.2.0-pre1
Comment 12 Parmendra Kumar 2016-04-13 16:31:57 UTC
I have checked this issue with Xamarin.Forms 2.2.0-pre2 and its working fine. To reproduce and verify I have used simulator (iPad Air2 iOS 9.2).

Hence closing this issue.
Comment 13 Parmendra Kumar 2016-04-13 17:11:35 UTC
Screncast: http://www.screencast.com/t/EJs8ayOeEIT