migueldeicaza / MonoTouch.Dialog

Tools to simplify creating dialogs with the user using MonoTouch
MIT License
430 stars 211 forks source link

GetHeight is ignored #183

Closed jede closed 10 years ago

jede commented 11 years ago

Hi!

The following code works (i.e. the element is 70 points high) with the version of Monotouch.Dialog bundled with the latest Xamarin, but not in master. Has the API changed since?

I've managed to find out that the correct source is assigned (SizingSource) but it seems as the GetHeightForRow method is never called.

Any ideas?

    public partial class MonoTestViewController : DialogViewController
    {
        public MonoTestViewController () : base(new RootElement("Test") { UnevenRows = true }) { }

        public class CustomElement : StringElement, IElementSizing
        {
            public CustomElement(string title) : base(title) { }

            public float GetHeight (UITableView tableView, NSIndexPath indexPath)
            {
                return 70f;
            }
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            Root.Add (new Section(){
                new CustomElement("hello")
            }); 
        }
    }
droyad commented 11 years ago

Does setting the following help? Root.UnevenRows = true

alexshikov commented 11 years ago

It won't work if you set this property after this.Root is applied.

Working example: var root = new RootElelemnt() { ... }; root.UnevenRows = true; this.Root = root;

NOT working example: this.Root = new RootElement() { ... }; this.Root.UnevenRows = true;

migueldeicaza commented 10 years ago

Tim confirms it works now.