Monotouch.Dialog: IElementSizing not used

I have a custom element class that only resizes when the device is rotated. At the initial display, the lines are not changed.

public class MultiImageElement : Element, IElementSizing

What implements the interface IElementSizing:

    #region IElementSizing implementation
    public float GetHeight (UITableView tableView, NSIndexPath indexPath)
    {
        return 78;
    }
    #endregion

However, this is never called, and the line height remains the default.

I add elements to my root in the loop:

for (int i = 0; i < secFolder.Rows; i++)
{
   sec.Add (new MultiImageElement (secFolder.ThumbnailPathsForRow (i), imageSize));
}
this.Root.Add (sec);
+3
source share
3 answers

I have found a solution.

To Monotouch.Dialogimplement IElementSizing, sections and elements must be added to the local variable myRoot.

After it has been built, install for it Dialog Root.

var myRoot = new Root();
MakeElements()
this.Root = myRoot;

It works.

+4
source

DialogViewController, Root.UevenRows true:

    public class CustomViewController : DialogViewController
    {
        public CustomViewController (RootElement root) : base(root)
        {
            Root.UnevenRows = true;
            ...
        }
        ...
     }
+3

It could not be connected, but it happened to me that the initial event of the rotation device was not released for me. So I applied the flag and triggered a scheduled selector that should be called when the application starts, to ensure that ShouldAutorotate ... was called and executed the layout for me, if necessary.

+1
source

All Articles