gpt4 book ai didi

iphone - UIPageViewController : get the currentPage

转载 作者:太空狗 更新时间:2023-10-30 03:11:22 32 4
gpt4 key购买 nike

过去几天我一直在为这个问题苦苦挣扎,在所有这些杂耍之后,我发现我所需要的只是数据源方法中的当前索引,以使用当前可见页码进行更新

我有这个 UIPageViewController 数据源方法,我需要使用当前索引来获取委托(delegate)方法的当前可见页面 previousViewControllers transitionCompleted:(BOOL)completed

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController {
NSString *path = [[NSBundle mainBundle] pathForResource:@"pages" ofType:@"pdf"];

NSURL *pdfurl = [NSURL fileURLWithPath:path];
PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfurl);

contentViewController = [[ContentViewController alloc] initWithPDFAtPath:path];

currentIndex = [modelArray indexOfObject:[(ContentViewController *)viewController page]];

if (currentIndex == totalPages - 1) {
return nil;
}

contentViewController.page = [modelArray objectAtIndex:currentIndex + 1];

return contentViewController;
}

我很困惑如何将当前索引语句从数据源方法写入委托(delegate)方法以更新当前可见页面。

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed{

if (!completed)
{
return;
}

//currentIndex = [[self.pageViewController.viewController lastObject]];
currentIndex = [self indexOfObject:contentViewController];

[self displaycurrentIndex:currentIndex];
//self.pageControl.currentPage = currentIndex;
}

我该如何纠正这个问题?

最佳答案

看起来你应该能够通过以下方式获取当前索引:

ContentViewController *viewController = [self.pageViewController.viewControllers lastObject];
currentIndex = [modelArray indexOfObject:[viewController page]];

关于iphone - UIPageViewController : get the currentPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17766832/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com