05-Hijacking The camera

  • 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開發範例大全第七章之六Hijacking The Camera(6a/14):2009年09月07日星期一 

iPhone SDK開發範例大全即iPhone Developer's CookBook的中文譯本,程式可由erica網站下載。第七章講Media(媒體資源),程式共有十一個(一個來自erica 3.0 c07-images、05-Hijacking The camera):

本文講第6個程式erica 3.0 c07-images、05-Hijacking The camera,CookBook 中文譯本7-8、259頁(但是不用訣竅7-6):

(A)這個程式有照一張相片,按下。如下圖。

 

(B)TestBedAppDelegate Class:

applicationDidFinishLaunching:

[UIApplication sharedApplication].idleTimerDisabled = YES; // default值為NO,現設為YES,screen將永遠開著耗電。

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[TestBedViewController alloc] init ]; // initWithRootViewController 的parameter為UIViewController

 

 

(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一次。