2

在 MonoTouch 上调用 UIGraphics.BeginPDFContext 时,我无法提供 PDF 文档信息。我已经尝试使用采用 CGPDFInfo 的重载和采用 NSDictionary 的重载,但是当我提供任何字符串值(例如作者)时,两者都会因 SIGSEGV 而崩溃。

以下代码导致 SIGSEGV:

var info = new CGPDFInfo()
{
    AllowsCopying = true,
    AllowsPrinting = true,
    Author = "My Name",// Setting any string property crashes
};
UIGraphics.BeginPDFContext(file, RectangleF.Empty, info); 

堆栈跟踪如下:

在 MonoTouch.Foundation.NSMutableDictionary.LowlevelSetObject (MonoTouch.Foundation.NSObject,intptr) [0x00011] 在 /Developer/MonoTouch /Source/monotouch/src/shared/Foundation/NSMutableDictionary.cs:394 在 /Developer/MonoTouch/Source/monotouch/src/shared/CoreGraphics/CGContextPDF.cs:161 中的 MonoTouch.CoreGraphics.CGPDFInfo.ToDictionary () [0x00033]在 MonoTouch.UIKit.UIGraphics.BeginPDFContext (string,System.Drawing.RectangleF,MonoTouch.CoreGraphics.CGPDFInfo) [0x00000] 在 /Developer/MonoTouch/Source/monotouch/src/UIKit/UIGraphics.cs:99

我也在Xamarin 论坛上问过这个问题,但没有得到任何答复。

我想使用将 NSMutableData 作为第一个参数的 BeginPDFContext 的重载,但这需要一个 NSDictionary 用于文档信息,我不知道如何为其提供不会崩溃的值。有任何想法吗?

4

1 回答 1

1

仅作记录:这是 MonoTouch 中的一个错误(现已修复)。

https://bugzilla.xamarin.com/show_bug.cgi?id=8879

于 2012-12-11T13:29:43.000 回答