我試圖鏈接內部使用AFNetworking
的本機iOS框架,我最初將其構建爲原型,將我公司的部分ObjC IP移植到可與Xamarin鏈接在將來。無法創建「FWSImageRepo」類型的本地實例。本地類尚未加載
我開始通過使加載使用AFNetworking小貓成的UIImageView一個簡單的類
頭文件
#import <UIKit/UIKit.h>
@interface FWSImageRepo : NSObject
+(UIImageView *)imageViewFromURLString:(NSString *)urlString;
@end
實施
@implementation FWSImageRepo
+(UIImageView *)imageViewFromURLString:(NSString *)urlString{
UIImageView *imageView = [[UIImageView alloc] init];
NSURL *imageUrl= [NSURL URLWithString:@"http://www.pets4homes.co.uk/images/articles/1334/large/6-health-issues-to-watch-for-in-young-kittens-52f62cff5cabb.jpg"];
if(imageUrl != nil) {
[imageView setImageWithURL:imageUrl];
}
return imageView;
}
@end
我創建了一個框架編譯器目標和我已經將框架複製到Xamarin iOS項目中。我用記號筆目的生成以下
// @interface FWSImageRepo : NSObject
[BaseType(typeof(NSObject))]
interface FWSImageRepo
{
// +(UIImageView *)imageViewFromURLString:(NSString *)urlString;
[Static]
[Export("imageViewFromURLString:")]
UIImageView ImageViewFromURLString(string urlString);
}
所有這些被鏈接的指示在binding project
綁定,框架被鏈接爲本地參考,並綁定項目是由一個單一頁面Xamarin iOS應用引用。
現在僅僅是初始化var fwrepo = new FWSImageRepo();
這個類就表示我完全不喜歡這個框架。即使我沒有鏈接綁定項目中的框架,錯誤也不會改變
Could not create an native instance of the type 'FWSImageRepo': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
任何理由檢查發生了什麼?我已經嘗試了一切,並在網上搜索了我的精力。只要我搜索過,沒有任何這方面的要求的例子,幾乎沒有任何方向。我已經嘗試了其他面臨相同問題的解決方案。我如何尋找我出錯的地方?
下面是我創建https://drive.google.com/open?id=0B2f9RlRxZKoZcElIRkpLZnF6WVU
是的,這聽起來對我來說也是如此,但我無法確定問題出在哪裏。感謝您的鏈接。 –