私の PDF スクロール ビュー ( Apple の ZoomingPDFViewer の例からコピーされましたが、少し変更されています) は、データを表示していますが、ズームできないようです。
Apple がこの例でそれを追加するために使用するものは次のとおりです。
CGPDFPageRef PDFPage = CGPDFDocumentGetPage(PDFDocument, 1);
[(PDFScrollView *)self.view setPDFPage:PDFPage];
そして、その2行目でエラーが発生したため、次のように変更しました。
CGPDFPageRef PDFPage = CGPDFDocumentGetPage(PDFDocument, 1);
PDFScrollView *sv = [[PDFScrollView alloc] initWithFrame:self.view.frame];
[sv setPDFPage:PDFPage];
self.view = sv;
しかし、今はPDFをズームできないようです。
Apple のものはエラーなしでうまく動作しますが、アプリでこの行を使用すると、そのビューの読み込み時に次のエラーが発生します。
-[UIView setPDFPage:]: unrecognized selector sent to instance 0x1c5b10b0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setPDFPage:]: unrecognized selector sent to instance 0x1c5b10b0'
*** First throw call stack:
(0x3424c2a3 0x33a1e97f 0x3424fe07 0x3424e531 0x341a5f68 0x8c499 0x36da3595 0x36df813b 0x36df8081 0x36df7f65 0x36df7e89 0x36df75c9 0x36df74b1 0x36de5b93 0x36de5833 0x79acd 0x36e46275 0x36ec8ea9 0x39249a6f 0x342215df 0x34221291 0x3421ff01 0x34192ebd 0x34192d49 0x34efb2eb 0x36dd8301 0x6e601 0x38e17b20)
libc++abi.dylib: terminate called throwing an exception
私のセットアップの他の唯一の違いは、これが呼び出されるView Controllerが、Tab Bar Controllerの内側にあるNavigation Controllerの内側にあることです。しかし、これが問題にどのように影響するかわかりません。
任意のヒント?
[アップデート]
これは私のカスタムinitメソッドです:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.decelerationRate = UIScrollViewDecelerationRateFast;
self.delegate = self;
self.scrollEnabled = true;
}
return self;
}
initWithCoder
を追加した以外は同じself.scrollEnabled = true;
です。
私もこれらを試しましたが、それでもうまくいきませんでした:
//UIScrollView *sv = [[UIScrollView alloc] initWithFrame:self.view.frame];
PDFScrollView *sv = [[PDFScrollView alloc] initWithFrame:self.view.frame];
self.view = sv;
[(PDFScrollView *)self.view setPDFPage:PDFPage];
コメントアウトされた行 (UIScrollView) を使用すると、同じエラーが表示されますが、[UIScrollView setPDFPage:]: unrecognized...
. コメントを外した行 (PDFScrollView) を使用すると、エラーは発生せず、PDF が表示されますが、ズームはまだ行われません。