使用transitionFromViewController 轉換 UIPageViewController - 跳頁

  • warning: Declaration of views_handler_argument::init(&$view, &$options) should be compatible with views_handler::init(&$view, $options) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • warning: Declaration of views_handler_filter::options_validate(&$form, &$form_state) should be compatible with views_handler::options_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter::options_submit(&$form, &$form_state) should be compatible with views_handler::options_submit($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter_boolean_operator::value_validate(&$form, &$form_state) should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • warning: Declaration of views_plugin_style_default::options(&$options) should be compatible with views_object::options() in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • warning: Declaration of views_plugin_row::options_validate($form, &$form_state) should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • warning: Declaration of views_plugin_row::options_submit($form, &$form_state) should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.

 一般UIPageViewController 使用viewControllerBeforeViewController及viewControllerAfterViewController來轉換到上一頁或下一頁,但是若想跳頁的話,怎麼辦?使用transitionFromViewController。

 

程式如下。

 

[self transitionFromViewController:pageControllerOld toViewController:pageController  duration:0.3 options:UIViewAnimationOptionTransitionCurlDown

      animations:^{

            //[pageControllerOld.view setAlpha:0.0];

                   }

     completion:^(BOOL finished) {

            [pageControllerOld removeFromParentViewController];

            [pageController didMoveToParentViewController:self];}

];

 

說明如下。

 

pageControllerOld跳至pageController,

duration是換頁的時間,

options:UIViewAnimationOptionTransitionCurlDown表示向下翻頁。

completion:時,

將舊的UIPageViewController pageControllerOld去掉removeFromParentViewController

[pageControllerOld removeFromParentViewController];

放上新的UIPageViewController 。

[pageController didMoveToParentViewController:self];