我正在尝试为 FastPDFKit 实现单点触控绑定。我在使用继承的构造函数时遇到问题。我正在尝试从 fastPDFKit 绑定“ReaderViewController”。ReaderViewController 继承自 MFDocumentViewController,MFDocumentViewController 继承自 UIViewController。
我的C#
NSUrl fullURL = new NSUrl (fullPath);
FastPDFKitBinding.MFDocumentManager DocManager = new FastPDFKitBinding.MFDocumentManager (fullURL);
DocManager.EmptyCache ();
//line where the errors occur
FastPDFKitBinding.ReaderViewController pdfView = new FastPDFKitBinding.ReaderViewController (DocManager);
pdfView.DocumentID = PageID.ToString ();
Source.PView.PresentViewController(pdfView, true, null);
这段代码没有构建,当我创建新的 ReaderViewController 时给了我两个错误:
Error CS1502: The best overloaded method match for `FastPDFKitBinding.ReaderViewController.ReaderViewController(MonoTouch.Foundation.NSCoder)' has some invalid arguments (CS1502) (iOSFlightOpsMobile)
Error CS1503: Argument `#1' cannot convert `FastPDFKitBinding.MFDocumentManager' expression to type `MonoTouch.Foundation.NSCoder' (CS1503) (iOSFlightOpsMobile)
我绑定的相关部分
namespace FastPDFKitBinding
{
[BaseType (typeof (UIAlertViewDelegate))]
interface MFDocumentManager {
[Export ("initWithFileUrl:")]
IntPtr Constructor (NSUrl URL);
[Export ("emptyCache")]
void EmptyCache ();
[Export ("release")]
void Release ();
}
[BaseType (typeof (UIViewController))]
interface MFDocumentViewController {
[Export ("initWithDocumentManager:")]
IntPtr Constructor (MFDocumentManager docManager);
[Export ("documentId")]
string DocumentID { get; set; }
[Export ("documentDelegate")]
NSObject DocumentDelegate { set; }
}
[BaseType (typeof (MFDocumentViewController))]
interface ReaderViewController {
}
}
现在,我可以通过从 MFDocumentViewController 获取绑定导出并将它们放入我的 ReaderViewController 接口来消除错误。
[BaseType (typeof (UIViewController))]
interface MFDocumentViewController {
}
[BaseType (typeof (MFDocumentViewController))]
interface ReaderViewController {
[Export ("initWithDocumentManager:")]
IntPtr Constructor (MFDocumentManager docManager);
[Export ("documentId")]
string DocumentID { get; set; }
[Export ("documentDelegate")]
NSObject DocumentDelegate { set; }
}
但我不想这样做,因为那些构造函数/方法是在 MFDocumentViewController 中定义的。如何让绑定正确使用那些继承的方法/构造函数。