MonoTouch本机崩溃调用CGPDFDictionary.GetArray

本文关键字:CGPDFDictionary GetArray 调用 崩溃 本机 MonoTouch | 更新日期: 2023-09-27 18:00:21

这里有5行试图获得关于一些随机PDF:的信息

        MonoTouch.CoreGraphics.CGPDFDocument oDoc = MonoTouch.CoreGraphics.CGPDFDocument.FromUrl("http://www.attachmate.com/NR/rdonlyres/C7BBC53C-CF9B-4C9C-AC3F-6C166526EC12/0/IDC_Attachmate_NetIQOverview2007.pdf");
        MonoTouch.CoreGraphics.CGPDFPage oPage = oDoc.GetPage(1);
        MonoTouch.CoreGraphics.CGPDFDictionary oDict = oPage.Dictionary;
        MonoTouch.CoreGraphics.CGPDFArray oArray;
        bool bResult = oDict.GetArray("Annots", out oArray);

最后一行(oDict.GetArray())崩溃如下:

本地堆栈:

0   Test_MT1                            0x000d1965 mono_handle_native_sigsegv + 343
1   Test_MT1                            0x0000ffb4 mono_sigsegv_signal_handler + 322
2   libSystem.B.dylib                   0x94a9705b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   CoreGraphics                        0x01055068 compare_key + 34
5   libSystem.B.dylib                   0x94a5f63d bsearch + 41
6   CoreGraphics                        0x010552a1 CGPDFDictionaryGetObject + 74
7   CoreGraphics                        0x010553fa CGPDFDictionaryGetArray + 31
8   ???                                 0x0ca253f6 0x0 + 211964918

有什么提示吗?

MonoTouch本机崩溃调用CGPDFDictionary.GetArray

这不是你的错,这是一个MonoTouch错误。

CGPDFDictionary是使用CGPDFPage句柄创建的(而它应该是通过调用CGPDFPageGetDictionary创建的)。

你可以通过在你的应用程序中添加pinvoke来解决这个错误:

[System.Runtime.InteropServices.DllImport ("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")]
private static extern IntPtr CGPDFPageGetDictionary (IntPtr pageHandle);

以及自己创建字典:

IntPtr handle = CGPDFPageGetDictionary (oPage.Handle);
    MonoTouch.CoreGraphics.CGPDFDictionary oDict = new MonoTouch.CoreGraphics.CGPDFDictionary (handle);