I am trying to bind WEPopover over to MonoTouch using btouch. It uses a UIBarButtonItem
category implementation to extend it's functionality to include presentation of the popover.
@interface UIBarButtonItem(WEPopover)
- (CGRect)frameInView:(UIView *)v;
- (UIView *)superview;
@end
How would I go about binding this into MonoTouch using a btouch interface definition?
My old answer missed the fact that categories were used. That was pointed out in the comments and the link to the Xamarin documentation did cover this. Quoting:
In Objective-C it is possible to extend classes with new methods, similar in spirit to C#'s extension methods. When one of these methods is present, you can use the
[Target]
attribute to flag the first parameter of a method as being the receiver of the Objective-C message.For example, in MonoTouch we bound the extension methods that are defined on
NSString
when UIKit is imported as methods in theUIView
, like this:
[BaseType (typeof (UIResponder))]
interface UIView {
[Bind ("drawAtPoint:withFont:")]
SizeF DrawString ([Target] string str, PointF point, UIFont font);
}
From: http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types#Binding_Class_Extensions
The above example is what MonoTouch uses to bind drawAtPoint:withFont:
which is part of the NSString UIKit Additions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With