Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fixing crashing on save static pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
derekblair committed Mar 22, 2017
1 parent 1af3757 commit 34ab0c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 7 additions & 2 deletions ILPDFKit/Controller/ILPDFViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIV
}
}

- (void)viewDidLoad {
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
}

#pragma mark - ILPDFViewController

#pragma mark - Setting the Document
Expand All @@ -57,8 +62,8 @@ - (void)reload {
#pragma mark - Private

- (void)loadPDFView {
if (self.pdfView.superview != nil) {
[self.pdfView removeFromSuperview];
if (_pdfView.superview != nil) {
[_pdfView removeFromSuperview];
}
_pdfView = [[ILPDFView alloc] initWithDocument:_document];
[self.view addSubview:_pdfView];
Expand Down
7 changes: 4 additions & 3 deletions ILPDFKit/View/ILPDFView.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ - (void)didMoveToWindow {
[_pdfView removeFromSuperview];
_pdfView = nil;
_uiWebPDFView = nil;
return;
}
if ([_pdfDocument.documentPath isKindOfClass:[NSString class]]) {
[self.pdfView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pdfDocument.documentPath]]];
} else {
[self.pdfView loadData:_pdfDocument.documentData MIMEType:ILPDFMIMEType characterEncodingName:ILPDFCharEncoding baseURL:[NSURL URLWithString:@"/"]];
} else if (_pdfDocument) {
[self.pdfView loadData:_pdfDocument.documentData MIMEType:ILPDFMIMEType characterEncodingName:ILPDFCharEncoding baseURL:nil];
}

}

- (void)layoutSubviews {
Expand All @@ -86,7 +88,6 @@ - (instancetype)initWithDocument:(ILPDFDocument *)document {
_tapGestureRecognizer.delegate = self;
[self addSubview:self.pdfView];
[self.pdfView pinToSuperview:UIEdgeInsetsZero];

}
return self;
}
Expand Down
4 changes: 2 additions & 2 deletions ILPDFKitExample/ILPDFKitExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

let savedVCDocument = ILPDFDocument(data: data!)

let alert : UIAlertController = UIAlertController(title: "Will Save PDF", message: "The PDF file displayed next is a static version of the previous file, but with the form values added. The starting PDF has not been modified and this static pdf no longer contains forms.", preferredStyle: .alert)
let alert = UIAlertController(title: "Will Save PDF", message: "The PDF file displayed next is a static version of the previous file, but with the form values added. The starting PDF has not been modified and this static pdf no longer contains forms.", preferredStyle: .alert)

let action = UIAlertAction(title: "Show Saved Static PDF", style: .default) { (_ : UIAlertAction) in
let action = UIAlertAction(title: "Show Saved Static PDF", style: .default) { _ in
alert.dismiss(animated: true, completion: nil)
self.pdfVC?.document = savedVCDocument
self.pdfVC?.navigationItem.setRightBarButton(nil, animated: false)
Expand Down

0 comments on commit 34ab0c2

Please sign in to comment.