UIPageViewController
ストーリーボードを使用してwith fourを作成しますUIViewController
が、最後の is が必要です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
何か案が?