我使用情节提要创建了UIPageViewController
四个,但我需要最后一个是. 有一种方法可以添加
或转换为UIViewController
UINavigationController
UINavigationController
UIPageViewController
UIViewController
UINavigationController
这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.dataSource = self ;
[self setViewControllers:@[self.pagina1]direction:UIPageViewControllerNavigationDirectionReverse animated: YES completion:nil ];
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"carbon.jpg"]];
[self.view addSubview:backgroundImage];
[self.view sendSubviewToBack:backgroundImage];
// [backgroundImage release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (ViewControllerPagina1 *) home1 {
if( !_home1 )
{
UIStoryboard *storyboard = self.storyboard ;
_home1 = [storyboard instantiateViewControllerWithIdentifier:@"Prima pagina"] ;
}
return _home1 ;
}
- (ViewControllerPagina2 *) home2 {
if( !_home2 )
{
UIStoryboard *storyboard = self.storyboard ;
_home2 = [storyboard instantiateViewControllerWithIdentifier:@"Seconda pagina"] ;
}
return _home2 ;
}
- (ViewControllerPagina3 *) home3 {
if( !_home3 )
{
UIStoryboard *storyboard = self.storyboard ;
_home3 = [storyboard instantiateViewControllerWithIdentifier:@"Terza pagina"] ;
}
return _home3 ;
}
- (UIViewController *) pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
UIViewController *nextViewController = nil ;
if( viewController == self.home1 ) nextViewController = self.home2 ;
else if( viewController == self.home2 ) nextViewController = self.home3 ;
else if( viewController == self.home3 ) nextViewController = self.home1 ;
return nextViewController ;
}
- (UIViewController *) pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
UIViewController *nextViewController = nil ;
if( viewController == self.home1 ) nextViewController = self.pagina3 ;
else if( viewController == self.home2 ) nextViewController = self.home1 ;
else if( viewController == self.home3 ) nextViewController = self.home2 ;
return nextViewController ;
}
实际上“home3”是一个UIViewController
,我需要把它转换成一个UINavigationController
任何想法?