gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 17:38:04 25 4
gpt4 key购买 nike

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

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

}

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

最佳答案

尝试查找下一个出现的位置:

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

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

关于objective-c - 在 Cocoa Mac Os X Objective-C 应用程序中,如何在 PDFView 当前显示的 pdf 页面中实现搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36815617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com