私はUIPageViewController
に大きな問題があります。私はセクションやサブセクションを使ってアプリケーションにコンテンツを表示したい。だから、私はUIPageViewController
の「2」インスタンスを作成している - 横(赤)と垂直方向(青):別の(水平)UIPageViewController内に(垂直)UIPageViewControllerをネストします
を私は「2」のインスタンスを作成していると述べた - それは紛れもない真実ではありません - 数十のインスタンスが存在する可能性がありますが、同時に2つしか提示されない場合、私はを知っています。どちらのコントローラーもtransitionStyle
はUIPageViewControllerTransitionStyleScroll
に設定されています。
赤色のUIPageViewController
は、セクション間の水平スクロールを担当し、ブルーは垂直スクロールを行います。
両者は分離されていますが、縦にUIPageViewController
を置くと、は縦に1つ動作しなくなります。私のコードは以下の通りである
:だけ明確にすること
水平UIPageViewController
作成
self.mainPageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:@{UIPageViewControllerOptionInterPageSpacingKey:[NSNumber numberWithFloat:0]}];
self.mainPageViewController.dataSource = self;
self.mainPageViewController.delegate = self;
self.pdfDocsURLs = @[ @{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1v" ofType:@"pdf"]],
@"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1h" ofType:@"pdf"]]},
@{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2v" ofType:@"pdf"]],
@"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2h" ofType:@"pdf"]]},
@{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"3v" ofType:@"pdf"]],
@"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"3h" ofType:@"pdf"]]}];
UIIndexedPageViewController *pvc = [[UIIndexedPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:@{UIPageViewControllerOptionInterPageSpacingKey:[NSNumber numberWithFloat:0]}];
pvc.index = 1;
PDFDocument *vdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[0][@"v"] password:nil];
PDFDocument *hdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[0][@"h"] password:nil];
PDFSinglePageViewController *svc = [[PDFSinglePageViewController alloc] initWithVerticalPDF:vdoc horizontalPDF:hdoc page:1];
[pvc setViewControllers:@[svc] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self.mainPageViewController setViewControllers:@[pvc] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
、UIIndexedPageViewController
は余分NSUInteger index
財産とUIPVCのサブクラスです。その実装は空です。メソッドを上書きしません。
UIPageViewController
のdataSource方法
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
if(pageViewController == self.mainPageViewController) { // if horizontal
UIIndexedPageViewController *ivc = (UIIndexedPageViewController *)viewController;
if(ivc.index == self.pdfDocsURLs.count) return nil;
UIIndexedPageViewController *pvc = [[UIIndexedPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:@{UIPageViewControllerOptionInterPageSpacingKey:[NSNumber numberWithFloat:0]}];
pvc.index = ivc.index+1;
PDFDocument *vdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[ivc.index][@"v"] password:nil];
PDFDocument *hdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[ivc.index][@"h"] password:nil];
PDFSinglePageViewController *svc = [[PDFSinglePageViewController alloc] initWithVerticalPDF:vdoc horizontalPDF:hdoc page:1];
[pvc setViewControllers:@[svc] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
return pvc;
} else { // if vertical - THE CODE BELOW IS NEVER EXECUTED
PDFSinglePageViewController *ovc = (PDFSinglePageViewController *)viewController;
NSUInteger nop = 0;
if(UIInterfaceOrientationIsPortrait(ovc.interfaceOrientation)) nop = ovc.verticalDoc.numberOfPages;
else if(UIInterfaceOrientationIsLandscape(ovc.interfaceOrientation)) nop = ovc.horizontalDoc.numberOfPages;
if(ovc.page == nop) return nil;
PDFSinglePageViewController *svc = [[PDFSinglePageViewController alloc] initWithVerticalPDF:ovc.verticalDoc horizontalPDF:ovc.horizontalDoc page:ovc.page+1];
return svc;
}
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
if(pageViewController == self.mainPageViewController) { // if horizontal
UIIndexedPageViewController *ivc = (UIIndexedPageViewController *)viewController;
if(ivc.index == 1) return nil;
UIIndexedPageViewController *pvc = [[UIIndexedPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:@{UIPageViewControllerOptionInterPageSpacingKey:[NSNumber numberWithFloat:0]}];
pvc.index = ivc.index-1;
PDFDocument *vdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[ivc.index-2][@"v"] password:nil];
PDFDocument *hdoc = [[PDFDocument alloc] initWithPDFFileURL:self.pdfDocsURLs[ivc.index-2][@"h"] password:nil];
PDFSinglePageViewController *svc = [[PDFSinglePageViewController alloc] initWithVerticalPDF:vdoc horizontalPDF:hdoc page:1];
[pvc setViewControllers:@[svc] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
return pvc;
} else { // is vertical - THE CODE BELOW IS NEVER EXECUTED
PDFSinglePageViewController *ovc = (PDFSinglePageViewController *)viewController;
NSUInteger nop = 0;
if(UIInterfaceOrientationIsPortrait(ovc.interfaceOrientation)) nop = ovc.verticalDoc.numberOfPages;
else if(UIInterfaceOrientationIsLandscape(ovc.interfaceOrientation)) nop = ovc.horizontalDoc.numberOfPages;
if(ovc.page == 1) return nil;
PDFSinglePageViewController *svc = [[PDFSinglePageViewController alloc] initWithVerticalPDF:ovc.verticalDoc horizontalPDF:ovc.horizontalDoc page:ovc.page-1];
return svc;
}
}
だから、水平UIPageViewController
は縦1でもパンジェスチャー認識装置を受信することはできませんようです。
私の質問はは垂直UIPageViewController
が両方向にタッチを受信してスクロールできるようにする方法はあります...ありますか?
ご協力いただければ幸いです。私は解決
-pageViewController:viewControllerBeforeViewController:
-pageViewController:viewControllerAfterViewController:
問題における私の垂直方向のページビューコントローラのdataSource
とdelegate
プロパティを割り当てるのを忘れ
あなたの役に立つ質問に感謝します。似たようなことをする。 – san