【问题标题】:In a Cocoa Mac Os X Objective-C Application, How to implement a Search in the pdf page currently displayed by a PDFView?在 Cocoa Mac Os X Objective-C 应用程序中,如何在 PDFView 当前显示的 pdf 页面中实现搜索?
【发布时间】:2016-04-23 19:48:15
【问题描述】:

我在 Cocoa 应用程序中搜索 PDFView 时遇到问题。现在我已经设置了一个 IBAction,其中包含用于选择特定单词(“继续”)的代码,我知道该单词位于我的测试中的当前 pdf 页面中。但是从未选择过单词,尽管我的代码正确收集了 PDFSelection 对象数组,只找到了 1 次。我的代码是:

-(IBAction)sampleAction:(id)sender
{
  NSArray *results = [self.pdfView.document findString:@"continue" withOptions:NSCaseInsensitiveSearch];

for (PDFSelection *pdfSel in results)
{

    [pdfSel drawForPage:self.pdfView.currentPage active:YES];

}

[self.pdfView scrollSelectionToVisible:self];

}

尽管如此,在当前显示的页面中,有继续这个词,但我没有选择。请帮忙!

【问题讨论】:

  • 尝试设置 PDFView 的当前选择。
  • 非常感谢!这似乎有效!

标签: objective-c cocoa pdf quartz-graphics


【解决方案1】:

尝试查找下一个匹配项:

PDFSelection *pdfSel=[self.pdfView.document findString: @"continue"
  fromSelection: self.pdfView.currentSelection
  withOptions: NSCaseInsensitiveSearch];

if (pdfSel != nil)
{
    [self.pdfView setCurrentSelection: pdfSel];
    [self.pdfView scrollSelectionToVisible: self];
}

【讨论】:

    猜你喜欢
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 2016-06-22
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多