Skip to content

Commit 7e70c69

Browse files
authored
Merge pull request #6 from interrobrian/master
Fix unpredictable failure on iOS
2 parents 842e306 + 63bd5f4 commit 7e70c69

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/share-file.ios.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export class ShareFile {
1010
}
1111
}
1212

13+
private controller: UIDocumentInteractionController;
14+
1315
open(args: any): boolean {
1416
if (args.path) {
1517
try {
1618
const appPath = this.getCurrentAppPath();
1719
const path = args.path.replace("~", appPath);
1820

19-
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
20-
controller.delegate = new UIDocumentInteractionControllerDelegateImpl2();
21+
this.controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
22+
this.controller.delegate = new UIDocumentInteractionControllerDelegateImpl2();
2123

2224
let rect;
2325
if (args.rect) {
@@ -26,16 +28,16 @@ export class ShareFile {
2628
rect = CGRectMake(0, 0, 0, 0);
2729
}
2830

29-
if ( args.options ) {
30-
return controller.presentOptionsMenuFromRectInViewAnimated(
31+
if (args.options) {
32+
return this.controller.presentOptionsMenuFromRectInViewAnimated(
3133
rect,
32-
controller.delegate.documentInteractionControllerViewForPreview(controller),
34+
this.controller.delegate.documentInteractionControllerViewForPreview(this.controller),
3335
args.animated ? true : false
3436
);
3537
} else {
36-
return controller.presentOpenInMenuFromRectInViewAnimated(
38+
return this.controller.presentOpenInMenuFromRectInViewAnimated(
3739
rect,
38-
controller.delegate.documentInteractionControllerViewForPreview(controller),
40+
this.controller.delegate.documentInteractionControllerViewForPreview(this.controller),
3941
args.animated ? true : false
4042
);
4143
}

0 commit comments

Comments
 (0)