我有一个PDF文件,其中包含要填写的字段。并用以下代码填充它们:
PDFDocument *documento = [[PDFDocument alloc] initWithData:dataFile];
for (int index = 0;index<documento.pageCount;index++) {
PDFPage *page = [documento pageAtIndex:index];
if (page != nil) {
NSArray *annotations = [[NSArray alloc] initWithArray:page.annotations];
for (PDFAnnotation *annotation in annotations ){
PDFAnnotation *annTemp = annotation.copy;
[annTemp setValue:[dizionarioForm objectForKey:[json objectForKey:annotation.fieldName]] forAnnotationKey:PDFAnnotationKeyWidgetValue];
[page removeAnnotation:annotation];
[annotation setShouldDisplay:false];
page.displaysAnnotations = false;
[page addAnnotation:annTemp];
}
}
}
self.pdfView = [[PDFView alloc] initWithFrame:self.view.frame];
self.pdfView.displayMode = kPDFDisplaySinglePage;
self.pdfView.autoScales = true;
self.pdfView.displayDirection = kPDFDisplayDirectionVertical;
self.pdfView.document = nil;
self.pdfView.document = documento.copy;
UIViewController *pdfVC = [[UIViewController alloc] init];
[pdfVC.view addSubview:self.pdfView];
pdfVC.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(pdfViewAzioni)];
[self.navigationController pushViewController:pdfVC animated:true];
但是,显示时,字段为白色,并且仅当我选择该字段时,该值才会显示... 如何立即显示该值? 谢谢。
答案 0 :(得分:0)
设置注释的背景颜色对我有用。选择的颜色似乎无关紧要。