gpt4 book ai didi

ios - 如何停止执行 PDFNet 操作?

转载 作者:行者123 更新时间:2023-11-29 12:39:08 24 4
gpt4 key购买 nike

基本上我正在尝试拦截对远程文件链接的点击,而是打开我已经存储的本地版本。

点击链接后,我能够了解链接的操作,但我不知道如何在保持 URL 不变的情况下阻止它执行默认行为。

相关代码如下:

- (void)pdfScrollViewTap:(UITapGestureRecognizer *)gestureRecognizer
{

Annot *annotation;

@try {
// If they are clicking an annotation, we don't want to process this
[self.pdfView DocLockRead];
CGPoint down = [gestureRecognizer locationInView:self.pdfView];
annotation = [self.pdfView GetAnnotationAt:down.x y:down.y];
}
@catch (NSException *exception) {
// something is wrong with the annotation, it may not be selected properly
}
@finally {
[self.pdfView DocUnlockRead];
}

// This is how we find out a Link was tapped
if ([annotation IsValid]) {
if (annotation.GetType == e_Link) { // Its a link
Link *link = [[Link alloc] initWithAnn:annotation]; // here's the link
Action *action = link.GetAction; // links have an action, heres that
if ([action IsValid]) { // hopefully its valid
if (action.GetType == e_URI) { // URI is the URL the link points to
if ([self.delegate respondsToSelector:@selector(shouldOpenURLforLinkAnnotation:withViewController:)]) { // Check if the delegate implements this
NSString *origURL = [action.GetSDFObj FindObj:@"URI"].GetAsPDFText;
if (![self.delegate shouldOpenURLforLinkAnnotation:origURL withViewController:self]) {
// The delegate handles finding and opening the local file

// Find a away to disable or stop the action here

}
}
}
}
}
return;
}
}

我试过简单地删除操作:

[link RemoveAction];

这第一次有效,但正如预期的那样,在删除它后再也不会调用该操作。

最佳答案

链接操作由工具代码执行,它实现了所有用户交互功能,例如文本选择、表单填写、注释创建/编辑和链接跟踪。要自定义链接处理行为,您应该在/Lib/src/PDFViewCtrlTools/Tools 中修改 AnnotEditTool.m 的源代码并编译 libTools.a 的新副本。相关代码部分是

else if( actionType == e_URI )
{
Obj* sdfObj = [action GetSDFObj];
Obj* uriObj = [sdfObj FindObj:@"URI"];

if( uriObj != Nil )
{
NSString* uriDestination = [uriObj GetAsPDFText];

// appends http if no scheme is present
uriDestination = [Link GetNormalizedUrl:uriDestination];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.4 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: uriDestination]];
});




return YES;
}
}

除了 openURL:

,你还想做点什么

关于ios - 如何停止执行 PDFNet 操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25488257/

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