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

質問編集履歴

1

コード修正しました

2017/10/24 13:38

投稿

usagi001
usagi001

スコア208

title CHANGED
File without changes
body CHANGED
@@ -4,17 +4,25 @@
4
4
  原因はdocInteractionControllerが破棄されたいたからのようでdocInteractionControllerをインスタンス変数にすることでファイル共有ができるようになったのですが、このdocInteractionControllerはどのタイミングで破棄すればいいのでしょうか?
5
5
 
6
6
  ###該当のソースコード
7
- NSString *filePath = ファイルのパス...
7
+ ```
8
- NSURL *url = [NSURL fileURLWithPath:filePath];
9
- UIDocumentInteractionController docInteractionController= [UIDocumentInteractionController interactionControllerWithURL:url];
10
- docInteractionController.delegate = self;
11
8
 
9
+ @implementation ViewController
10
+ - (IBAction)tappedButton:(UIButton *)button
11
+ {
12
+ NSString *filePath = ファイルパス...;
13
+ NSURL *url = [NSURL fileURLWithPath:filePath];
14
+ UIDocumentInteractionController *docInteractionController
15
+ = [UIDocumentInteractionController interactionControllerWithURL:url];
16
+ docInteractionController.delegate = self;
17
+
12
- BOOL result = [docInteractionController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
18
+ BOOL result = [docInteractionController presentOptionsMenuFromRect:button.frame inView:self.view animated:YES];
13
-
19
+
14
- if (!result){
20
+ if (!result){
15
- // アラート表示...
21
+ // アラート表示...
22
+ }
16
23
  }
17
24
 
25
+ ```
18
26
  ###補足情報(言語/FW/ツール等のバージョンなど)
19
27
  環境Xcode9.0
20
28
  言語Objective-C