質問するログイン新規登録

質問編集履歴

2

質問文を見直し

2019/06/25 17:21

投稿

yrema
yrema

スコア287

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,75 @@
1
+ いくつか頂いた情報で質問文を書き換えました。
2
+
3
+ UIDocumentInteractionControllerによりPDFをAdobe Acrobat Readerに送ってコメント入れて保存したPDFを受け取りたいのですが、
4
+ 下記のコードでResouces内のsample.pdfをAdobe Acrobat Readerに送って開くことは出来たのですが、戻り方が分からず困っています。
5
+ Androidは確か共有機能で外部アプリ起動後に戻ったことを検知できたはずなので、それと同じことがやりたいです。
6
+ ```c#
7
+ public partial class ViewController : UIViewController, IUIDocumentInteractionControllerDelegate
8
+ {
9
+ public ViewController (IntPtr handle) : base (handle)
10
+ {
11
+ }
12
+
13
+ public override void ViewDidLoad ()
14
+ {
15
+ base.ViewDidLoad ();
16
+
17
+ UIButton button = new UIButton(new CGRect(0, 0, 100, 100));
18
+ button.Center = View.Center;
19
+ button.BackgroundColor = UIColor.Blue;
20
+ button.TouchUpInside += OnClicked;
21
+ View.AddSubview(button);
22
+ }
23
+
24
+ private void OnClicked(object sender, EventArgs e)
25
+ {
26
+ string fileName = "sample.pdf";
27
+
28
+ // Resourcesのパスを取得
29
+ string resourcesPath = NSBundle.MainBundle.BundlePath;
30
+ // PDFのパスを取得
31
+ string pdfPath = Path.Combine(resourcesPath, fileName);
32
+
33
+ // Documentのパスを取得
34
+ string documentPath = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0];
35
+
36
+ if (NSFileManager.DefaultManager.FileExists(pdfPath))
37
+ {
38
+ // 外部アプリで開く
39
+ NSUrl copyDstPathUrl = new NSUrl(pdfPath, false);
40
+ UIDocumentInteractionController dic = UIDocumentInteractionController.FromUrl(copyDstPathUrl);
41
+ dic.Delegate = this;
42
+ if (!dic.PresentOpenInMenu(new CGRect(0, 0, 500, 500), View, true))
43
+ {
44
+ Console.WriteLine("ファイルに対応するアプリがありません", this);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ ▼UIDocumentInteractionControllerが表示されたところ([Acrobatにコピー]をクリック)
52
+ ![イメージ説明](aa1169e5175018ebc63b4ea7c482fdd0.png)
53
+
54
+ ▼Adobe Acrobat Readerを起動して取り消し線を入れた後に、右上のメニューを見て「もしかして戻れないんじゃないか」と思い始めたところ
55
+ ![イメージ説明](ab8f8a9bed20de3791fc0d65c1859b95.png)
56
+
57
+
58
+ ◆開発環境
59
+ ▼実機デバイス
60
+ iPad 9.7インチ Wi-Fiモデル 32GB MRJN2J/A
61
+ ▼Windows 10
62
+ Visual Studio Community 2017 Version 15.9.11
63
+ Xamarin 4.12.3.83
64
+ Xamarin.iOS and Xamarin.Mac SDK 12.4.0.64
65
+ ▼Mac mini(Late 2014)
66
+ macOS Majave 10.14.4
67
+ Xcode 10.2.1
68
+
69
+
70
+ 以下編集前の質問文============================================
71
+
1
- タイトルの通りですが、
72
+ ~~タイトルの通りですが、
2
73
  アプリからPDFを外部ビューアで起動し、ファイルが変更されたことを元のアプリが検知することはできるでしょうか?
3
-
4
74
  ★環境
5
- iOS 12以上 objective-c、swift、xamarinなど言語は問いません。
75
+ iOS 12以上 objective-c、swift、xamarinなど言語は問いません。~~

1

変更はファイルと明記

2019/06/25 17:21

投稿

yrema
yrema

スコア287

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  タイトルの通りですが、
2
- アプリからPDFを外部ビューアで起動し、変更があったことを元のアプリが検知することはできるでしょうか?
2
+ アプリからPDFを外部ビューアで起動し、ファイルが変更されたことを元のアプリが検知することはできるでしょうか?
3
3
 
4
4
  ★環境
5
5
  iOS 12以上 objective-c、swift、xamarinなど言語は問いません。