gpt4 book ai didi

ios - viewControllerAfterViewController : does not get called with UIPageViewController

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:40:42 26 4
gpt4 key购买 nike

我遇到了 UIPageViewController 的一个非常奇怪的行为。

我正在使用 UIPageViewController 显示一组 ViewController,因此我遵循 UIPageViewControllerDataSource 协议(protocol),并实现了以下方法:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(NHBufferRoomViewController *)viewController
{
NSLog(@"Got here!!");
NSInteger newIndex = [_imageManager currentImageIdx] + 1;
if (newIndex >= [_imageManager count]) return nil;

NSLog(@"%d", newIndex);
NHBufferRoomViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"BufferRoom"];
[controller updateImageAtIndex:newIndex];
[[NSNotificationCenter defaultCenter] postNotificationName:kCurrentImageIndex object:[NSNumber numberWithInteger:newIndex]];
return controller;
}

但是当我滑动页面 View Controller 时,有时 View Controller 确实移动到下一页,但是 NSLog(@"Got here!!"); 直到我才被调用再次滑动,这很奇怪。据我了解,页面 View Controller 应该在需要显示新页面时调用此方法,对吗?但是为什么没有调用该方法?

顺便说一句,我正在将过渡类型设置为滚动。提前致谢!

最佳答案

是的,你是对的。它的问题是苹果的 api。

解决方案:不要使用 UIPageViewController,而是通过带分页的 UIScrollView 实现它

关于ios - viewControllerAfterViewController : does not get called with UIPageViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20533162/

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