Tag: 绑定

Xamarin绑定在设备上失败,但在模拟器中工作

我创build了一个带有一个函数的Objective-C库。头文件被定义为: @interface StarIOFunctions : NSObject { } + (NSMutableData *) GetDataToSendToPrinter:(UIImage *)image maxWidth:(int)maxWidth drawerKick:(BOOL)drawerKick compressionEnable:(BOOL)compressionEnable; @end 我为它创build了一个绑定: [BaseType (typeof (NSObject))] interface StarIOFunctions { [Static, Export ("GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:")] NSMutableData GetDataToSendToPrinter (UIImage image, int maxWidth, bool kickDrawer, bool compressionEnable); } 而通过它的呼吁: image = UIImage.FromBundle("barcode.png"); NSMutableData commandsToPrint = StarIOFunctions.GetDataToSendToPrinter(image,576,true,true); 所有在模拟器中工作正常,但是当我释放到设备的应用程序崩溃,当它试图调用具有以下错误的函数: 2014-09-30 19:10:52.776 DemoApp[280:26219] +[StarIOFunctions GetDataToSendToPrinter:maxWidth:drawerKick:compressionEnable:]: unrecognized selector sent to […]

绑定iOS Xamarin的embedded式框架END UP给予exception?

请帮助我的最后一步。 谢谢。 我testing绑定的iOS本机框架Xamarin库。 我创build了iOS框架并添加了MyView.h,MyView.m MyView.m (instancetype)initWithFrame:(CGRect)frame {id p = [super initWithFrame:frame]; self.backgroundColor = [UIColor greenColor]; 返回p; } MyView.h @interface MyView:UIView @end 非常简单的框架。 将MyView.h添加到公共标题中,并为任何体系结构创build通用框架。 这个框架现在已经 firstfile.h,MyView.h 两个文件作为公共标题 我创build了iOStesting应用程序(单个VC应用程序),并尝试这个框架。 MyView * v = [[MyView alloc] initWithFrame:CGRectMake(0,0,100,100)]; [self.view addSubview:v]; 它按我的预期工作。 它画了一个绿色的盒子。 我创build了Xamarin Library项目,并通过点击鼠标右键并添加文件,将这个框架文件导入本地参考文件夹 将此行添加到Xamarin库中的ApiDefinition.cs中 [BaseType(typeof(UIView))]接口MyView {[Export(“initWithFrame:”)] IntPtr构造函数(CGRect框架); } build立好。 我创build了Xamarin.iOS应用程序,并将此库导入到解决scheme并进行testing。 MyView v = new MyView(new CGRect(0,0,100,100)); this.View.AddSubview(V); 编好! […]

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; […]

如何将Objective-C静态库绑定到Xamarin.iOS?

我已经阅读了Xamarin的文档。 这是Objective-C中的testing类: #import "XamarinBundleLib.h" @implementation XamarinBundleLib +(NSString *)testBinding{ return @"Hello Binding"; } @end 这很简单,只是一种方法。 这是我的C#类: namespace ResloveName { [BaseType (typeof (NSObject))] public partial interface IXamarinBundleLib { [Static,Export ("testBinding")] NSString TestBinding {get;} } } 那么这是我的AppDelegate代码: public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required […]