2016-07-11 10 views
0

私はXcodeにPage-Based ApplicationRootViewController,DataViewController,ModelController)のテンプレートを使用しています。私は時間間隔の後にページを反転したい。どうしたらいいですか?フリップ次のページ時間間隔の後にどのようにフリップページ?

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController 
{ 
    NSUInteger index = [self indexOfViewController:(DataViewController *)viewController]; 
    if (index == NSNotFound) { 
     return nil; 
    } 

    index++; 
    if (index == [self.pageData count]) { 
     return nil; 
    } 
    return [self viewControllerAtIndex:index storyboard:viewController.storyboard]; 
} 

答えて

0

ため

コードは、私は、これはあなたが

HomeViewController *homeVC = [[HomeViewController alloc] init]; 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homeVC]; 
[UIView transitionFromView:self.view toView:nav.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) { 
            //Action to Implement 
          }]; 

[または]

HomeViewController *homeVC = [[HomeViewController alloc] init]; 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homeVC]; 
nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
nav.modalPresentationStyle = UIModalPresentationFormSheet; 
[[self navigationController] presentViewController:nav animated:YES completion:^{ 
       //Action to implement 
      }]; 
+0

どのコントローラーをコードで使用する必要がありますか? – user214155

+0

このコードは、反転させたいコントローラーで使用できます。 –

+0

ex:コントローラAはあなたの現在のクラスです。その後、このコードを特定のアクションに追加します。コードは別のコントローラに移動します。B –

0

時間間隔使用dispatch_after後に反転するに役立つことを願っています。

// define fromViewController depend on your previous code 
UIViewController *toViewController = [self pageViewController:pageViewController viewControllerAfterViewController:viewController]; 
// or set another toViewController depend on your previous code 

NSTimeInterval interval = 5; //in seconds 
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(interval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 
    [UIView transitionFromView:fromViewController.view toViewController:toViewController.view duration:0.4 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) { 
     //completion block 
    }]; 
}); 
+0

https: //drive.google.com/file/d/0B0EJbcHq3ZALRVQxbGhfcHVpeDg/view?usp=sharing – user214155

+0

私は「あなたのコードでfromViewControllerを定義する」と書いています。私は私の答えを少し変えます。 – Igor

+0

このスニペットをコードに合わせて調整する必要があります。私はコードであなたのコントローラの名前を知らない。 – Igor

関連する問題