我的工作流程设置如下:
导航控制器
-VC1
-VC2
-VC3
-PageVC
--VC4
--VC5
我通过第一个控制器将一个对象(例如 UIImage 引用)传递给 PageVC。在这里,PageVC 会按如下方式加载控制器:
- (void) viewDidLoad {
[super viewDidLoad];
self.dataSource = self;
_side = [self.storyboard instantiateViewControllerWithIdentifier: @"GuessGameTurnWordVC"];
_center = [self.storyboard instantiateViewControllerWithIdentifier: @"GuessGameTurnMainVC"];
[self setViewControllers: @[_center]
direction: UIPageViewControllerNavigationDirectionForward
animated: NO
completion: nil];
}
- (UIViewController*) pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
if ( viewController == _center )
{
_side.title = @"right";
return _side;
}
if ( viewController == _side && [_side.title isEqualToString: @"left"] )
{
return _center;
}
return nil;
}
- (UIViewController*) pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
if ( viewController == _center )
{
_side.title = @"left";
return _side;
}
if ( viewController == _side && [_side.title isEqualToString: @"right"] )
{
return _center;
}
return nil;
}
问题
在 VC4/VC5 中,我需要从 PageVC 访问一个属性。我怎样才能做到这一点?
我是否也需要将属性传递给这些控制器,或者我可以以某种方式直接从其父级访问它?