我有以下ViewControllers结构:
PageViewController包含PhotoViewController和VideoViewController,它以编程方式更改,因此没有任何segues。
我希望允许VideoControlViewController使用CameraViewController中的方法。我尝试使用以下代码:
self.videoControlViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"videoControlViewController"];
self.videoControlViewController.delegate = self;
它不起作用,因为方法" instantiateViewControllerWithIdentifier"创建VideoViewController的新实例。这是我发现的同样问题的主题:
如果没有任何segue或过渡,如何将self.VideoControlViewController指向故事板中的实例?
- (void)viewDidLoad {
[super viewDidLoad];
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.viewControllers = @[@"photoControlViewController", @"videoControlViewController"];
self.pageViewController.dataSource = self;
[[self.pageViewController view] setFrame:[[self view] bounds]];
[self.pageViewController setViewControllers:[NSArray arrayWithObject:[self viewControllerAtIndex:[self.viewControllers indexOfObject:@"photoControlViewController"]]] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageViewController];
[[self view] addSubview:[self.pageViewController view]];
[self.pageViewController didMoveToParentViewController:self];
}