我在Root UIPageViewController中有一个滑块,需要将滑块值传递给子视图控制器。除了已经加载的子视图控制器之外,它适用于其他子视图控制器!
我在RootView中使用Slider进行滑块值更改我已调用 -
- (void)sliderValueChanged:(UISlider *)slider {
fontValue = slider.value;
DetailsVC *dataViewController = [self viewControllerAtIndex:self.newsIndex storyboard:self.storyboard];
[dataViewController refreshViewForFontSize:slider.value];
}
我有通常的UIPageViewController方法,它工作正常。问题是它只能在子ViewControllers
中调用ViewDid Load方法后才能工作- (DetailsVC *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard {
// Return the data view controller for the given index.
if (([self.pageContent count] == 0) || (index >= [self.pageContent count])) {
return nil;
}
DetailsVC *dataViewController = [[DetailsVC alloc] init];
dataViewController.fontValue = fontValue;
return dataViewController;
}
答案 0 :(得分:0)
终于找到了解决方案
DetailsVC *dataViewController = [self viewControllerAtIndex:currentIndex-1 storyboard:self.storyboard];
dataViewController.textColor = textColor;
NSArray *viewControllers = @[dataViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
重新加载子视图控制器的当前方法是通过
获取它setViewControllers:direction:animated:completion:
如果有人需要一个示例项目,我上传了它 https://github.com/bishalg/BGPageViewController