dataSource更改后动态重新加载UIPageViewController [英] Dynamically reload UIPageViewController after dataSource changed

查看:468
本文介绍了dataSource更改后动态重新加载UIPageViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

so I'm trying to create an ibooks-like reader and I need to update the contents of the UIPageViewController dynamically after I get the data from the webservice. For a long series of reasons I have to instantiate it at the beginning and then update it when the data comes.

我正在创建它:

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有这样的东西吗?

I'm looking for something like reloadData for a UITableViewController, is there such a thing for UIPageViewController?

推荐答案

主要问题是webview拦截了所有用户触摸,因此UiPageViewController没有调用委托方法。设置webview以忽略用户触摸事件后,一切都开始正常工作。

The main problem was that the webview was intercepting all the user touches and therefore the UiPageViewController wasn't calling the delegate methods. Once set the webview to ignore user touch events everything started to work properly.

这篇关于dataSource更改后动态重新加载UIPageViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆