Objective c PDFAnnotationText未在10.12上显示弹出窗口

Objective c PDFAnnotationText未在10.12上显示弹出窗口,objective-c,cocoa,annotations,macos-sierra,pdf-annotations,Objective C,Cocoa,Annotations,Macos Sierra,Pdf Annotations,PDFAnnotationText在macOS sierra 10.12.1测试版(16B2548a)上未显示弹出窗口PDFAnnotationText在10.12上不推荐使用,但新的API不是绘图注释 旧API: // display the PDF document [m_pdfView setDocument: [self pdfDocument]]; - (PDFDocument *)pdfDocument { // create a page PDFDocu

PDFAnnotationText
在macOS sierra 10.12.1测试版(16B2548a)上未显示弹出窗口
PDFAnnotationText
在10.12上不推荐使用,但新的API不是绘图注释

旧API:

// display the PDF document
    [m_pdfView setDocument: [self pdfDocument]];

- (PDFDocument *)pdfDocument {
    // create a page

    PDFDocument *document = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"/Users/test/Downloads/Eticket.pdf"]];
    PDFAnnotationText* result = [[PDFAnnotationText alloc] initWithBounds:NSMakeRect(100, 100, 40, 40)];
    result.color = [NSColor redColor];
    result.contents = @"Hello";
    result.iconType = kPDFTextAnnotationIconNote;
    // add it to the PDF document
    [[document pageAtIndex:0] addAnnotation:result];
    return document;
}
10.12新的API:

- (PDFDocument *)pdfDocument {
    // create a page
    PDFDocument *document = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"/Users/test/Downloads/Eticket.pdf"]];

    NSMutableDictionary *popupDictionary = [[NSMutableDictionary alloc] init];

    [popupDictionary setObject:@"/Popup" forKey:kPDFAnnotationKey_Subtype];
    [popupDictionary setObject:[NSColor redColor] forKey:kPDFAnnotationKey_Color];
    [popupDictionary setObject:@"Hello" forKey:kPDFAnnotationKey_Contents];

    NSValue *rectValue = [NSValue valueWithRect:NSMakeRect(100, 100, 40, 40)];
    [popupDictionary setObject:rectValue forKey:kPDFAnnotationKey_Rect];

    PDFAnnotation *textAnnotation = [[PDFAnnotation alloc] initWithDictionary: popupDictionary forPage: [document pageAtIndex:0]];
    [[document pageAtIndex:0] addAnnotation:textAnnotation];    // add it to the PDF document
    return document;
}

我使用的是Xcode版本8.0(8A218a)。有人能帮我吗?

我可以创建一个简单的黑色字符串注释,如下所示(在Swift 3中):

它使用/FreeText,但如果您尝试使用这些值,它可能会对您有所帮助。仍然无法确定如何更改文本的颜色

let document = pdfView!.document
let page = document!.page(at:0)
let pageBounds = page!.bounds(for: PDFDisplayBox.artBox)
let annotation = PDFAnnotation()
annotation.setValue("/FreeText", forAnnotationKey: kPDFAnnotationKey_Subtype)
annotation.setValue("HELLO WORLD", forAnnotationKey: kPDFAnnotationKey_Contents)
annotation.setValue(NSColor.clear, forAnnotationKey: kPDFAnnotationKey_Color)
annotation.bounds = NSRect(x:10, y:pageBounds.height-50, width:400, height:40)
page!.addAnnotation(annotation)