我需要通过使用按钮的IBaction使用Adobe Reader应用程序打开本地PDF [英] I need to open a local PDF using Adobe Reader app via an IBaction using a Button

查看:109
本文介绍了我需要通过使用按钮的IBaction使用Adobe Reader应用程序打开本地PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找解决问题的方法几天,却找不到我真正需要的东西.我创建了一个交互式PDF,需要在Adobe Reader中查看(该应用程序位于ipad上).我有多个视图控制器,我需要向其中添加一个通用按钮,这将打开Adobe Reader以显示pdf(通过弹出式窗口显示到应用程序或嵌入式,嵌入式首选).目前,当我单击我的按钮时,屏幕只是略微变暗,然后在再次触摸后恢复正常.基于我正在寻找的内容,我假设这将是通过IBaction进行的,目前,我有以下内容:

I have been searching for days for a solution to my problem and cant find exactly what I need. I have created an interactive PDF that needs to be viewed in Adobe Reader (the app is on the ipad). I have multiple view controllers I need to add a universal button to that will open Adobe Reader to show the pdf (via popover to the app or embedded, embedded preferred). Currently when i click my button, the screen just slightly dims, then goes back to normal after a second touch. Based on what im looking for, I am assuming this will be via an IBaction and I currently have the following:

h个文件:

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) IBOutlet UIWebView *webView;
@end

m个文件:

#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) UIDocumentInteractionController *controller;
@end

@implementation ViewController
@synthesize webView;

//code for pdf file

- (IBAction)openDocument:(id)sender {

NSURL *adobeURL = [[NSBundle mainBundle] URLForResource:@"Interactive_Collateral_Form" withExtension:@"pdf"];
self.controller = [UIDocumentInteractionController interactionControllerWithURL:adobeURL];
self.controller.delegate = self;
self.controller.UTI = @"com.adobe.pdf";

[self.controller presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
    }

//code for background gif image

- (void)viewDidLoad
{
NSString *pathImg = [[NSBundle mainBundle] pathForResource:@"background" ofType:@"gif"];
NSString* webViewContent = [NSString stringWithFormat:
                            @"<html><body><img style='width:760;height:1024;' src=\"file://%@\"     /></body></html>", pathImg];
[webView loadHTMLString:webViewContent baseURL:nil];

webView.scrollView.bounces = NO;
webView.scrollView.scrollEnabled = NO;
webView.opaque=FALSE;
[webView setBackgroundColor:[UIColor clearColor]];
      }

我假设我可以将相同的代码添加到所有不同的视图控制器中.如果那不是真的,请告诉我.我对此并不擅长,因此您可以提供的任何详细信息都会有所帮助.预先谢谢你!

I am assuming I can add the same code to all the different view controllers. If that is not true, let me know. Im not great at this so any details you can give would be helpful. Thank you in advance!

推荐答案

经过大量研究,我弄清楚该怎么做.我将本地PDF保存在Adobe Reader应用程序中.从那里,我添加了以下URL方案,以使我的按钮无需使用UIDocumentInteractionController即可在Adobe Reader中打开PDF.然后只需将IBAction链接到您的按钮即可.

After much research, I figured out what to do. I saved the local PDF in the Adobe Reader app. From there, I added the following url scheme to have my button open the PDF in the Adobe reader without using a UIDocumentInteractionController. Then just link the IBAction to your button.

h个文件:

- (IBAction)adobeButton;

m个文件:

- (IBAction)adobeButton {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"com.adobe.Adobe-Reader://Interactive_Collateral_Form.pdf"]];
}

这篇关于我需要通过使用按钮的IBaction使用Adobe Reader应用程序打开本地PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆