07e-FlipViewSwipe

  • 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.

iPhone SDK開發範例大全第二章之十三Swipe(13/14):2009年09月03日星期四

iPhone SDK開發範例大全即iPhone Developer's CookBook的中文譯本,程式可由erica網站下載。第二章講View(視圖),程式共有十四個:

本文講第13個程式07e-FlipViewSwipe,CookBook 中文譯本2-11、95頁:

(A)這個程式讓使用者click後往上下左右swipe,圖就會依方向更換。如下圖。往右或往上。

 

(B)先用loadView load進兩張圖片:先load backside.png ( 97~100行 ) ,再load frontside.png ( 108~112行) 。

 

(C) FlipView class是主軸,其中instance variable,startTouchPosition及dirString表示click開始點及swipe方向。init會setMultipleTouchEnabled。

getAnimation: direction會得到animation 的方向。 注意:試試uncomment 25行及comment 26行,改一下type,會成為flip。

(D)touchesBegan時,將startTouchPosition記下。

touchesMoved時,

49~52行,由 ( startTouchesPosition.x - currentTouchPosition.x ) 及( startTouchesPosition.y - currentTouchPosition.y ) 判斷是否橫向移動。

61~64行,由 ( startTouchesPosition.y - currentTouchPosition.y )及 ( startTouchesPosition.x - currentTouchPosition.x ) 判斷是否縱向移動。

touchesEnded時,

80~86行:若有dirString時,作移動的animation動作。