08-AffineRotate

  • 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開發範例大全第二章之十四AffineRotate(14/14):2009年09月04日星期五

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

本文講第14個程式08-AffineRotate,CookBook 中文譯本2-12、98頁:

(A)這個程式有一不斷旋轉及縮小的動畫。如下圖。此為Affine的功能。

(B)instance variable theta為旋轉角度。

 

(C)handleTimer。

每次rotate pi的 1%。

25行,CGAffineTransformCGAffineTransformMakeRotation

32行,CGAffineTransforScale(transform, degree, degree),

35行,self.view returns UIView; viewWithTag 傳回 UIview ;setTransform ,default 是 CGAffineTransformIdentity

We can also modify this program to the following:

float angle = theta * ( PI /10);

CGAffineTransform transform = CGAffineTransformMakeRotation(angle);

theta = (theta + 1) % 200;

CGAffineTransform rotateIt = CGAffineTransformRotate (transform, rotateIt);

[[self.view viewWithTag: ROTATE_VIEW_TAG] setTransfor: rotateIt];

then the picture will rotate 10 times a roll.

If it is too fast, change line 53 to scheduledTimeWithTimerInterval:1.0f 。

 

(D)loadView。

53行,NSTimer, scheduledTimerWithTimeInterval有四個parameter。

(NSTimeInterval) secondes:多久firing the timer。

target:(id) target :送messsage 的target(與selector一起決定)。

selector : (SEL) aSelector: 送給target約selector。必需是 -(void) timerFireMethod: (NSTimer *) theTimer 。

userInfo:(id) userInfo:可以是nil。

repeats:(BOOL) repeats: YES則每隔 secondes就firm timer一次。