0

私はhttp://www.vfr.org/、pdf ビューアーを使用しており、IBOOK で PDF を開くためのボタンを追加しようとしています。

ボタンとアクションを追加しましたが、このpdfでibooksアプリケーションを開きたい瞬間に行き詰まりました。

私は2つの解決策を試しました:

  1. ボタンタップアクション:

    NSURL *fileURL = document.fileURL;
    NSString *fileName = document.fileName; // Document
    [[UIApplication sharedApplication] openURL:fileURL];
    

IBOOKS を開きますが、PDF は読み込まれません。

URL 形式が間違っている可能性があると想定しています。次のような PDF URL をハードコードしてみました。

NSString *stringURL = @"itms-books://linktopdf.pdf";     
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

でも同じ結果。

2) ボタンタップアクション:

    NSURL *fileURL = document.fileURL;
    NSString *fileName = document.fileName; // Document
    UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc] init];
    docController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    docController.delegate = self;

しかし、委任しようとすると警告が表示されます。 docController.delegate = self;

assigning to id UIDocumentInteractionControllerDelegate from Incompatible ReaderViewController

誰かがこれらのソリューションの少なくとも 1 つを機能させるのを手伝ってくれますか?

4

2 に答える 2

1

ReaderViewControllerのヘッダー ファイルには、次のような行があります@interface ReaderViewController : NSObject < UIDocumentInteractionControllerDelegate >

于 2013-02-12T14:41:38.540 に答える
0

クラスはUIDocumentInteractionControllerDelegate プロトコルに準拠する必要があるため、.h ファイルで次のようにします。

@interface ReaderViewController : PerantClass <UIDocumentInteractionControllerDelegate>
{

...

}

次に、コンパイラは、クラスがそのプロトコルに準拠していることを認識します。もちろん、必要なメソッドを実装する必要があります。

また、このリンク - 1とリンク - 2も確認してください

于 2013-02-12T14:46:46.930 に答える