1

「developer.apple.com」のZoomingPDFViewerソース コードを使用して、PDF ファイルを表示しようとしました。私のコードの違いは、いくつかの機能を追加するために Nib ファイルを使用していることです。ソース コードから PDFScrollView および TiledPDFView クラス ファイルを使用しているだけです。メソッド [(PDFScrollView *)self.view setPDFPage:PDFPage]; を呼び出そうとすると、次のエラーが表示されます。

Smart_Reader [408:f803] -[UIView setPDFPage:]: インスタンス 0x6ea09b0 に送信された認識ないセレクターsent to instance 0x6ea09b0' * First throw call stack: (0x1283022 0x183bcd6 0x1284cbd 0x11e9ed0 0x11e9cb2 0x2a49 0x489e29 0x489133 0x48a3bf 0x48ca21 0x48c97c 0x4853d7 0x1ea1a2 0x1ea532 0x1d0dc4 0x1c4634 0x2176ef5 0x1257195 0x11bbff2 0x11ba8da 0x11b9d84 0x11b9c9b 0x21757d8 0x217588a 0x1c2626 0x1e5d 0x1dc5) terminate called throwing an exception

私はobjective-cに非常に慣れていないため、これがstackoverflow.comへの最初の投稿です。この素晴らしいコミュニティからの助けに感謝します

PDFReader.h

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@interface ReaderViewController : UIViewController //<UIScrollViewDelegate>
{
    IBOutlet UILabel *TapLabel;
}



- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer;


@end

PDFReader.m

#import "ReaderViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "TiledPDFView.h"
#import "PDFScrollView.h"
#import "singleton.h"

@interface ReaderViewController ()

@end

@implementation ReaderViewController
{

}



- (void)viewDidLoad
{

    [super viewDidLoad];
    self.view.backgroundColor = [UIColor clearColor];

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

    NSString *name = [infoDictionary objectForKey:@"NEWGEN KNOWLEDGE WORKS"];
    NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];

    self.title = [NSString stringWithFormat:@"GENIUS READER",name,version];

    TapLabel.backgroundColor = [UIColor clearColor];
    TapLabel.textColor = [UIColor whiteColor];
    TapLabel.textAlignment = UITextAlignmentCenter;
    TapLabel.font = [UIFont systemFontOfSize:24.0f];

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
    singleTap.numberOfTouchesRequired = 1; singleTap.numberOfTapsRequired = 1; //singleTap.delegate = self;
    [self.view addGestureRecognizer:singleTap];

}


- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}


-(void)handleSingleTap:(UITapGestureRecognizer *)recognizer
{

    NSInteger Totalpages;

    NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"fw4" withExtension:@"pdf"];

    CGPDFDocumentRef myDocument;

    myDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef) pdfURL);// 1

    if (myDocument == NULL) {// 2

        CFRelease ((__bridge CFURLRef)pdfURL);
    }

    CFRelease ((__bridge CFURLRef) pdfURL);

    Totalpages =   CGPDFDocumentGetNumberOfPages(myDocument);

    if (Totalpages == 0) {// 5
        CGPDFDocumentRelease(myDocument);
        }

    CGPDFPageRef PDFPage = CGPDFDocumentGetPage(myDocument, 1);


    //[c setPDFPage:PDFPage];


    //PDFScrollView *PDFview = [[PDFScrollView alloc] init];
    //[PDFview setPDFPage:PDFPage];
    //[self.view addSubview:[singleton glpData].testsingleton]; 
    [(PDFScrollView *)self.view setPDFPage:PDFPage];

}

@end
4

1 に答える 1

2

アップルがその例で示したのと同じコードを使用しているようです。

IBを使用している場合は、IBでIBOutletsを接続していることを確認してください

(or)

IBを使用していない場合は、viewDidLoadでPDFScrollViewを開始したことを確認してください

この回答を参照してください-> ZoomingPDFViewerのエラー例

于 2012-07-11T06:34:07.933 に答える