gpt4 book ai didi

ios - 数据源更改后动态重新加载 UIPageViewController

转载 作者:可可西里 更新时间:2023-11-01 04:19:12 24 4
gpt4 key购买 nike

所以我正在尝试创建一个类似 ibooks 的阅读器,我需要在从 web 服务获取数据后动态更新 UIPageViewController 的内容。由于一系列原因,我必须在开始时实例化它,然后在数据到来时更新它。

我是这样创建的:

NSDictionary *options =
[NSDictionary dictionaryWithObject:
[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
forKey: UIPageViewControllerOptionSpineLocationKey];

self.pageController = [[UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options: options];

self.pageController.dataSource = self;
self.pageController.delegate = self;

[[self.pageController view] setFrame:[[self view] bounds]];

MovellaContentViewController *initialViewController = [self viewControllerAtIndex:0];

self.controllers = [NSArray arrayWithObject:initialViewController];

[self.pageController setViewControllers:self.controllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];

[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];

然后我设置 self.controllers = newControllersArray;

我正在为 UITableViewController 寻找类似 reloadData 的东西,UIPageViewController 有这样的东西吗?

最佳答案

你必须再次发送 setViewControllers:direction:animated:completion: 到 pageController并给它第一个显示的 View Controller :

[self.pageController setViewControllers:[NSArray arrayWithObject:
[self viewControllerAtIndex:0]
]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];

如果 viewControllerAtIndex: 没有像我最初假设的那样访问 self.controllers,它可能应该是

[self.pageController setViewControllers:[NSArray arrayWithObject:
[self.controllers objectAtIndex:0]
]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];

代替

关于ios - 数据源更改后动态重新加载 UIPageViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11884816/

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