के अंदर घूमना मुझे अपने UIPageViewController
के साथ एक बड़ी समस्या है। मैं अनुभाग और उप-वर्गों का उपयोग करके अपने ऐप में सामग्री प्रस्तुत करना चाहता हूं। क्षैतिज (लाल) और ऊर्ध्वाधर (नीला) - तो, मैं "दो"UIPageViewController
के उदाहरण बनाया है:एक (लंबवत) UIPageViewController को किसी अन्य (क्षैतिज) UIPageViewcontroller
इससे पहले मैंने कहा कि मैं बनाया है "दो" उदाहरणों - यह पूरी तरह सच नहीं है - उदाहरणों के दसियों हो सकते हैं, लेकिन एक ही समय में केवल 2 प्रस्तुत किए जाते हैं, आप जानते हैं कि मेरा क्या मतलब है। दोनों नियंत्रकों के पास transitionStyle
UIPageViewControllerTransitionStyleScroll
पर सेट है।
लाल UIPageViewController
अनुभागों और नीले रंग के बीच क्षैतिज स्क्रॉलिंग के लिए ज़िम्मेदार है लंबवत स्क्रॉलिंग के लिए जिम्मेदार हैं।
वे दोनों अलग होने पर काम करते हैं, लेकिन जब मैं क्षैतिज UIPageViewController
क्षैतिज में डालता हूं तो लंबवत एक काम करना बंद कर देता है। बस स्पष्ट होना
क्षैतिज 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
डेटा स्रोत तरीकों
- (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
खड़ी एक भी पैन इशारा recognizers प्राप्त करने के लिए अनुमति नहीं है।
मेरा प्रश्न है ... वहाँ खड़ी UIPageViewController
दोनों दिशाओं में अंतिम रूप प्राप्त करते हैं और स्क्रॉल करने के लिए अनुमति देने के लिए कोई तरीका है?
किसी भी मदद की सराहना की जाएगी।
आपके उपयोगी प्रश्न में दिशा के लिए धन्यवाद। कुछ ऐसा करना – san