Incorrect conversion value for CGSize/SizeF binding

845 Views Asked by At

I'm working on MonoTouch binding project to integrate GMGridView into my application. I was able to successfully load the empty Grid view but was not able to load grid items. After spending hours on MonoTouch & Objective C code, it turned out that System.Drawing.SizeF binding is incorrectly translating to CGSize (i.e, SizeF(140f, 110f) is translating to CGSize(140, 0) - value of height is lost).

Objective C Definition

    - (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation;

Monotouch Binding

    [Abstract, Export ("GMGridView:sizeForItemsInInterfaceOrientation:")]
    System.Drawing.SizeF SizeForItemsInInterfaceOrientation (GMGridView gridView, UIInterfaceOrientation orientation);

I was wondering if I'm binding it incorrectly or this is a known bug? Also, what would be a resolution other than creating additional callback for height value.

Binding and test code is posted here: GMGridMono

Thanks for looking into this.

1

There are 1 best solutions below

0
On

I have encountered the same issue with bindings to a method returning CGSize. Monotouch V5.2.12. It happens on the simulator but not on the device. A direct call from a mono application to the method works fine, but when the method is used as a callback from the bound library to the mono code the returned Height value is incorrect and appears ininitialized.