首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何绑定CGPDFDocumentRef?

如何绑定CGPDFDocumentRef?
EN

Stack Overflow用户
提问于 2013-03-03 18:44:27
回答 2查看 383关注 0票数 1

我假设应该将CGPDFDocumentRef绑定到CGPDFDocument

我正在尝试下面的方法

代码语言:javascript
复制
    //- (id)initWithPDFDocument:(CGPDFDocumentRef)_document filepath:(NSString *)fullFilePath;
    [Export("initWithPDFDocument:filepath:")]
IntPtr Constructor (CGPDFDocument document, string path);

我还包括:

代码语言:javascript
复制
using MonoTouch.CoreGraphics;

当我尝试编译我的绑定项目时,我得到了以下错误:

代码语言:javascript
复制
: error BI1002: btouch: Unknown kind MonoTouch.CoreGraphics.CGPDFDocument document in method 'pdftest.ReaderDocument.Constructor'

编辑:

从poupou输入后,我得到了以下内容:

代码语言:javascript
复制
    [BaseType (typeof (NSObject))]
    partial interface ReaderDocument {

    [Export("initWithPDFDocument:filepath:")] 
    [Internal] IntPtr Constructor (IntPtr document, string path);

在extras.cs中:

代码语言:javascript
复制
    public partial class ReaderDocument {
        public ReaderDocument (CGPDFDocument doc, string path) : this (doc.Handle, path) { }
    }

我可以在MonoDevelop中构建我的绑定项目,但我在btouch中得到了以下错误。我使用命令"/Developer/MonoTouch/usr/bin/btouch MyBindingLib.cs -s:extras.cs“

代码语言:javascript
复制
MyBindingLib.cs(12,19): error CS0260: Missing partial modifier on declaration 
of type `mybindingtest.ReaderDocument'. Another partial declaration of this type 
exists
extras.cs(6,30): (Location of the symbol related to previous error)
extras.cs(6,30): error CS0261: Partial declarations of `mybindingtest.ReaderDocument' 
must be all classes, all structs or all interfaces
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-03 23:17:19

btouch不知道存在的所有类型,只知道基本类型和您定义的类型。在这种情况下,您可以通过两个步骤来绑定它。

首先将CGPDFDocumentRef绑定为IntPtr,并将其修饰为[Internal]

代码语言:javascript
复制
[Export("initWithPDFDocument:filepath:")]
[Internal]
IntPtr Constructor (IntPtr document, string path);

接下来,在Extra.cs文件中添加一个自定义构造函数。

代码语言:javascript
复制
partial public class YourType {
   public YourType (CGPDFDocument doc, string path) : this (doc.Handle, path) { }
}
票数 1
EN

Stack Overflow用户

发布于 2013-03-05 00:11:19

在核心图形研讨会上有一个使用CGPDFDocument的例子:

http://www.youtube.com/watch?v=MNxVMYKaZP0

相关代码如下:

https://github.com/xamarin/Seminars/blob/master/2012-01-26-CoreGraphics/XaminarPDFDemo/XaminarPDFDemo/PDFView.cs

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15184829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档