Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch Dialog StringElements Variable Cell Height

I am having a problem overriding the GetHeight method when developing an iPad application with MonoTouch.Dialog. I am implementing IElementSizing but my GetHeight method never gets called.

Has anyone else ran into this problem? Thanks.

I made sure that my root.UnevenRows = true;

I also tried including the dialog project and placing a breakpoint in the GetHeight() for any of the Elements that implement IElementSizing with no luck. In a previous iPhone project this worked fine but on the iPad I am still stuck. Are there any other 'gotchas' that I could be missing?

like image 987
Rick Make Avatar asked Nov 11 '11 19:11

Rick Make


1 Answers

This is sort of a bug in MonoTouch.Dialog. Basically, when you assign the Root Element it wants to know whether there are uneven rows so it can create and cache the appropriate UITableViewSource object.

However, if you add Sections with Elements that implement IElementSizing to the Root element after the Source object has already been created. Then it will not call your GetHeight override. An example of this is if you fetch data async and callback and add the resulting Sections / Elements to to the RootElement...or essentially anytime you add Sections / Elements after PrepareRoot() is called.

There is a simple workaround for this:

this.Root.UnevenRows = true;

Without looking at your code however, I cannot say if this is the bug you are seeing.

like image 121
Anuj Avatar answered Nov 19 '22 05:11

Anuj