2011-12-27 10 views
3

私はUIDocumentinteractioncontrollerを使用して、ibookのような他のアプリケーションでpdfを開きます。ibooksのような他のアプリケーションでpdfを開く方法

しかし、それについての文書を見つけるのは難しいです。

ここでは、一部を公開することができます。しかし、私はibooksのアイコンをクリックします。何も起こらない。

私は、documentInteractionController:willBeginSendingToApplication:のようなデリゲートで何かする必要がありますか?

+0

回答は、次のポスト http://stackoverflow.com/questions/6741565/docinteraction-sample-code-uidocumentinteractioncontroller-broken-on-ios-4にあり-3秒 – ArunaFromLK

答えて

0

は、まず、あなたの.hファイル

IEでUIDocumentInteractionControllerDelegateを追加する必要があります:あなたは見つけることができますプロトコルを、追加.mファイルに

@interface MyDocumentViewController : UIViewController <UIDocumentInteractionControllerDelegate> 

、何が起こります..もちろん。

- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{ 
    NSLog(@"Send to App %@ ...", application); 
} 

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application{ 
    NSLog(@"Finished sending to app %@ ...", application); 

} 

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller{ 
    NSLog(@"Bye"); 

} 

あなたは、このモジュールにUIDocumentInteractionControllerのデリゲートを設定する必要があります。私はこのようにそれを解決:

-(BOOL)canOpenDocumentWithURL:(NSURL*)url inView:(UIView*)view { 
    BOOL canOpen = NO; 
    UIDocumentInteractionController* tmpDocController = [UIDocumentInteractionController 
                 interactionControllerWithURL:url]; 
    if (tmpDocController) 
    { 
     tmpDocController.delegate = self; 
     canOpen = [tmpDocController presentOpenInMenuFromRect:CGRectZero 
                inView:self.view animated:NO];     
     [tmpDocController dismissMenuAnimated:NO]; 
    } 
    return canOpen; 
} 
関連する問題