Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Cocoa Mac Os X Objective-C应用程序中,如何在PDFView当前显示的pdf页面中实现搜索?_Objective C_Cocoa_Pdf_Quartz Graphics - Fatal编程技术网

在Cocoa Mac Os X Objective-C应用程序中,如何在PDFView当前显示的pdf页面中实现搜索?

在Cocoa Mac Os X Objective-C应用程序中,如何在PDFView当前显示的pdf页面中实现搜索?,objective-c,cocoa,pdf,quartz-graphics,Objective C,Cocoa,Pdf,Quartz Graphics,我在Cocoa应用程序中搜索PDFView时遇到问题。现在,我已经设置了一个iAction,其中包含用于选择特定单词(“continue”)的代码,我知道该单词驻留在我测试的当前pdf页面中。尽管我的代码正确地收集了PDFSelection对象数组,但从未选择该词,只找到一个匹配项。我的代码是: -(IBAction)sampleAction:(id)sender { NSArray *results = [self.pdfView.document findString:@"continu

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

-(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];

}

尽管如此,在当前显示的页面中,单词continue仍然存在,但我没有选择。请帮忙

尝试使用以下命令查找下一个事件:

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

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

尝试使用以下命令查找下一个匹配项:

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

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

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