在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);
堆栈跟踪如下:
at(wrapper managed-to-native)MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr(intptr,intptr,intptr,intptr) 在/Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSMutableDictionary.cs:394中的MonoTouch.Foundation.NSMutableDictionary.LowlevelSetObject(MonoTouch.Foundation.NSObject,intptr)[0x00011] 在/Developer/MonoTouch/Source/monotouch/src/shared/CoreGraphics/CGContextPDF.cs:161中的MonoTouch.CoreGraphics.CGPDFInfo.ToDictionary()[0x00033] 在/Developer/MonoTouch/Source/monotouch/src/UIKit/UIGraphics.cs:99的MonoTouch.UIKit.UIGraphics.BeginPDFContext(string,System.Drawing.RectangleF,MonoTouch.CoreGraphics.CGPDFInfo)[0x00000]中
我也在Xamarin Forum上提出了问题,但没有得到答案。
我想使用BeginPDFContext的重载,它将NSMutableData作为第一个参数,但是需要一个NSDictionary作为文档信息,我不知道如何为它提供不会崩溃的值。有什么想法吗?