我是MonoTouch開發的新手,我想在我的應用程序中嵌入一些PDF查看功能。我已經找到了幾個資源來做這件事,但是,我還看到有關所有其他實現的足夠的評論,以使其穩定和快速。綁定到Objective C庫(VFR閱讀器)
我現在看到有哪些已經實現了很多功能了良好的ObjectiveC庫(CATiledLayer,多線程,頁面滾動,拇指指甲,設備旋轉...):https://github.com/vfr/Reader
最後的日子,在閱讀monotoch綁定文檔後,我試圖在MonoTouch中綁定這個,但沒有成功。 我可以將它導出到一個庫(.a)文件,並且我創建了一個綁定API。
//@interface ReaderDocument : NSObject <NSObject, NSCoding>
[BaseType (typeof (NSObject))]
interface ReaderDocument {
//- (id)initWithFilePath:(NSString *)fullFilePath password:(NSString *)phrase;
[Export("initWithFilePath:password")]
IntPtr Constructor (string path, string phrase);
//Properties
[Export("guid")]
string Guid { get;}
[Export("fileDate")]
NSDate FileDate { get;}
[Export("lastOpen")]
NSDate LastOpen { get;set;}
[Export("fileSize")]
NSNumber FileSize{ get;}
[Export("pageCount")]
NSNumber PageCount { get;}
[Export("pageNumber")]
NSNumber PageNumber { get;set;}
[Export("bookmarks")]
NSMutableIndexSet Bookmarks { get;}
[Export("fileName")]
string FileName { get;}
[Export("password")]
string Password { get;}
[Export("fileURL")]
NSUrl FileURL { get;}
//Methods
//+ (ReaderDocument *)withDocumentFilePath:(NSString *)filename password:(NSString *)phrase;
[Static, Export("withDocumentFilePath:password")]
ReaderDocument WithDocumentFilePath(string filename, string phrase);
//+ (ReaderDocument *)unarchiveFromFileName:(NSString *)filename password:(NSString *)phrase;
[Static, Export("unarchiveFromFileName:password")]
ReaderDocument UnarchiveFromFileName(string filename, string phrase);
//- (void)saveReaderDocument;
[Export("saveReaderDocument")]
void SaveReaderDocument();
//- (void)updateProperties;
[Export("updateProperties")]
void updateProperties();
}
我對下面的行BTW非常不確定:
//@interface ReaderDocument : NSObject <NSObject, NSCoding>
[BaseType (typeof (NSObject))]
interface ReaderDocument
不知道如果我必須做的「」什麼?
我現在可以在MonoTouch中創建下面的代碼
ReaderDocument doc = ReaderDocument.withDocumentFilePath("Tamarin.pdf","");
或
ReaderDocument doc = new ReaderDocument("Tamarin.pdf","yrt");
兩者都導致 「無法識別的選擇」 錯誤
2012-11-04 22:15:05.731 PFDTest1[4149:1507] +[ReaderDocument withDocumentFilePath:password]: unrecognized selector sent to class 0x2f7738
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[ReaderDocument withDocumentFilePath:password]: unrecognized selector sent to class 0x2f7738
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSend_IntPtr_IntPtr (intptr,intptr,intptr,intptr)
at VFRBinding4.ReaderDocument.withDocumentFilePath (System.String filename, System.String phrase) [0x00000] in <filename unknown>:0
at PFDTest1.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00030] in /Users/matthiasvalcke/Projects/PFDTest1/PFDTest1/AppDelegate.cs:39
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at PFDTest1.Application.Main (System.String[] args) [0x00000] in /Users/matthiasvalcke/Projects/PFDTest1/PFDTest1/Main.cs:17
任何想法?
嘿@Matt,您是否成功創建了vfr-reader的綁定?我有一個類似的問題,一點幫助會非常棒! – chritaso