2013年4月25日木曜日

 アプリケーションメニューの表示

外部アプリケーションのメニュ=を表示し、ファイルをアプリに送る


UIDocumentInteractionControllerは、iOS4から使えるが、facebook,twitter,Printなどは出てこない。
iOS6なら、UIActivityViewControllerを使う方よい。

ここでは、UIDocumentInteractionControllerのサンプルを載せる。




UIDocumentInteractionController *docInterCon;



    //データへのURL
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *dataFilePath = [bundle pathForResource:@"file" ofType:@".text"];
    NSURL *url = [NSURL fileURLWithPath:dataFilePath];
    
    //
    self.docInterCon = [UIDocumentInteractionController interactionControllerWithURL:url];
    self.docInterCon.delegate = self;
        
    //アプリケーションのメニューを表示
    BOOL isValid;
    isValid = [self.docInterCon presentOptionsMenuFromBarButtonItem:_barbtn animated:YES];
    if (!isValid){
        NSLog(@"アプリケーションがありません");
    }

0 件のコメント:

コメントを投稿