Xamarin绑定类别返回错误:无法在静态类中声明实例成员
我试图绑定ReFrostedViewController到C#。 我使用Objective Sharpie生成接口。 但是当我使用Xamarin来编译它时,它会返回错误。
/REFrostedViewController_UIViewController.g.cs(10,10): Error CS0708: `REFrostedMenu.REFrostedViewController_UIViewController.__mt_FrostedViewController_var': cannot declare instance members in a static class (CS0708) (REFrostedBinding)
这是我的代码:
[Export ("frostedViewController", ArgumentSemantic.Retain)] REFrostedViewController FrostedViewController { get; }
我改变它如下:
[Export ("frostedViewController", ArgumentSemantic.Retain)] REFrostedViewController FrostedViewController()
它可以编译,但我不能得到它的formsUIViewController。
REFrostedViewController reFrost = base.FrostedViewController();
它返回错误:
/MainViewController.cs(43,43): Error CS0117: `MonoTouch.UIKit.UIViewController' does not contain a definition for `FrostedViewController' (CS0117) (iOS)
更新:这是完整的代码
using System; using System.Drawing; using MonoTouch.ObjCRuntime; using MonoTouch.Foundation; using MonoTouch.UIKit; namespace REFrostedMenu { [BaseType (typeof (UIViewController))] public partial interface REFrostedContainerViewController { [Export ("screenshotImage", ArgumentSemantic.Retain)] UIImage ScreenshotImage { get; set; } [Export ("frostedViewController", ArgumentSemantic.Assign)] REFrostedViewController FrostedViewController { get; set; } [Export ("animateApperance")] bool AnimateApperance { get; set; } [Export ("containerView", ArgumentSemantic.Retain)] UIView ContainerView { get; } [Export ("panGestureRecognized:")] void PanGestureRecognized (UIPanGestureRecognizer recognizer); [Export ("hide")] void Hide (); [Export ("resizeToSize:")] void ResizeToSize (SizeF size); // [Export ("hideWithCompletionHandler:")] // void HideWithCompletionHandler(HideCompletionHandler handler); [Export ("refreshBackgroundImage")] void RefreshBackgroundImage (); } [BaseType (typeof (UIViewController))] public partial interface REFrostedViewController { [Export ("panGestureRecognizer", ArgumentSemantic.Retain)] UIPanGestureRecognizer PanGestureRecognizer { get; } [Export ("panGestureEnabled")] bool PanGestureEnabled { get; set; } // [Export ("direction")] // REFrostedViewControllerDirection Direction { get; set; } [Export ("backgroundFadeAmount")] float BackgroundFadeAmount { get; set; } [Export ("blurTintColor", ArgumentSemantic.Retain)] UIColor BlurTintColor { get; set; } [Export ("blurRadius")] float BlurRadius { get; set; } [Export ("blurSaturationDeltaFactor")] float BlurSaturationDeltaFactor { get; set; } [Export ("animationDuration")] double AnimationDuration { get; set; } [Export ("limitMenuViewSize")] bool LimitMenuViewSize { get; set; } [Export ("menuViewSize", ArgumentSemantic.Assign)] SizeF MenuViewSize { get; set; } [Export ("liveBlur")] bool LiveBlur { get; set; } // [Export ("liveBlurBackgroundStyle")] // REFrostedViewControllerLiveBackgroundStyle LiveBlurBackgroundStyle { get; set; } // [Export ("delegate", ArgumentSemantic.Assign)] // REFrostedViewControllerDelegate Delegate { get; set; } [Export ("contentViewController", ArgumentSemantic.Retain)] UIViewController ContentViewController { get; set; } [Export ("menuViewController", ArgumentSemantic.Retain)] UIViewController MenuViewController { get; set; } [Export ("initWithContentViewController:menuViewController:")] IntPtr Constructor (UIViewController contentViewController, UIViewController menuViewController); [Export ("presentMenuViewController")] void PresentMenuViewController (); [Export ("hideMenuViewController")] void HideMenuViewController (); [Export ("resizeMenuViewControllerToSize:")] void ResizeMenuViewControllerToSize (SizeF size); // [Export ("hideMenuViewControllerWithCompletionHandler:")] // void HideMenuViewControllerWithCompletionHandler (HideMenuViewControllerCompletionHandler handler); [Export ("panGestureRecognized:")] void PanGestureRecognized (UIPanGestureRecognizer recognizer); } [BaseType (typeof (NSObject))] [Model] public partial interface REFrostedViewControllerDelegate { [Export ("frostedViewController:willAnimateRotationToInterfaceOrientation:duration:")] void WillAnimateRotationToInterfaceOrientation (REFrostedViewController frostedViewController, UIInterfaceOrientation toInterfaceOrientation, double duration); [Export ("frostedViewController:didRecognizePanGesture:")] void DidRecognizePanGesture (REFrostedViewController frostedViewController, UIPanGestureRecognizer recognizer); [Export ("frostedViewController:willShowMenuViewController:")] void WillShowMenuViewController (REFrostedViewController frostedViewController, UIViewController menuViewController); [Export ("frostedViewController:didShowMenuViewController:")] void DidShowMenuViewController (REFrostedViewController frostedViewController, UIViewController menuViewController); [Export ("frostedViewController:willHideMenuViewController:")] void WillHideMenuViewController (REFrostedViewController frostedViewController, UIViewController menuViewController); [Export ("frostedViewController:didHideMenuViewController:")] void DidHideMenuViewController (REFrostedViewController frostedViewController, UIViewController menuViewController); } [BaseType (typeof (UIImage))] [Category] public partial interface REFrostedViewController_UIImage { [Export ("re_applyBlurWithRadius:tintColor:saturationDeltaFactor:maskImage:")] UIImage Re_applyBlurWithRadius (float blurRadius, UIColor tintColor, float saturationDeltaFactor, UIImage maskImage); [Export ("re_screenshot")] UIImage Re_screenshot (); } [BaseType (typeof (UIViewController))] [Category] public partial interface REFrostedViewController_UIViewController { [Export ("frostedViewController", ArgumentSemantic.Retain)] REFrostedViewController FrostedViewController(); [Export ("re_displayController:frame:")] void Re_displayController (UIViewController controller, RectangleF frame); [Export ("re_hideController:")] void Re_hideController (UIViewController controller); } }
请帮助我,我非常感谢!
我创build了一个绑定项目和示例作为一个叉子Github上: https : //github.com/therealjohn/REFrostedViewController
“不能在静态类中声明实例成员”的错误是因为
[Export ("frostedViewController", ArgumentSemantic.Retain)] REFrostedViewController FrostedViewController { get; }
哪个试图创build一个类别中的属性,这基本上是一个扩展方法。 有没有“扩展”的C#属性,所以你的方法更改“固定”,错误。
我不确定你还有什么其他问题,但是我所做的项目应该为你工作。
请享用!