我一直在寻找解决问题的方法,但无法找到我需要的东西。我创建了一个需要在Adobe Reader中查看的交互式PDF(该应用程序位于ipad上)。我有多个视图控制器,我需要添加一个通用按钮,将打开Adobe Reader以显示pdf(通过popover到应用程序或嵌入式,嵌入式首选)。目前,当我点击我的按钮时,屏幕稍微变暗,然后在第二次触摸后恢复正常。基于我正在寻找什么,我假设这将通过IBaction,我目前有以下内容:
h file:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) IBOutlet UIWebView *webView;
@end
m file:
#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]];
}
我假设我可以将相同的代码添加到所有不同的视图控制器。如果不是这样,请告诉我。我不是很擅长,所以你能给出的任何细节都会有所帮助。提前谢谢!
答案 0 :(得分:0)
经过大量研究,我想出了该怎么做。我在Adobe Reader应用程序中保存了本地PDF。从那里,我添加了以下url方案,让我的按钮在Adobe Reader中打开PDF而不使用UIDocumentInteractionController。然后将IBAction链接到您的按钮。
h file:
- (IBAction)adobeButton;
m file:
- (IBAction)adobeButton {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"com.adobe.Adobe-Reader://Interactive_Collateral_Form.pdf"]];
}