animationViewController.h
#import <UIKit/UIKit.h> @interface animationViewController : UIViewController { IBOutlet UIImageView *images; } @property(nonatomic, retain) UIImageView *images; -(IBAction)start:(id)sender; -(IBAction)stop:(id)sender; @end
animationViewController.m
#import "animationViewController.h" @implementation animationViewController @synthesize images; -(IBAction)start:(id)sender{ images.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"1.jpg"], [UIImage imageNamed:@"2.jpg"], [UIImage imageNamed:@"3.jpg"], [UIImage imageNamed:@"4.jpg"], [UIImage imageNamed:@"5.jpg"], [UIImage imageNamed:@"6.jpg"], nil]; images.animationDuration = 3; images.animationRepeatCount = 0; [images startAnimating]; [self.view addSubview:images]; } -(IBAction)stop:(id)sender{ [images stopAnimating]; } - (void)viewDidLoad { [super viewDidLoad]; images.image = [UIImage imageNamed:@"0.jpg"]; [self.view addSubview:images]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end
参考
YouTube - iPhone SDK Tutorial: Image Animationhttp://www.youtube.com/watch?v=a267i4qYcB0&feature=related&hd=1
詳解 Objective-C 2.0 改訂版: 荻原 剛志 | iPhoneプログラミングUIKit詳解リファレンス: 所 友太, 京セラコミュニケーションシステム株式会社 | iPhone SDK アプリケーション開発ガイド: Jonathan Zdziarski, 近藤 誠 (監訳), 武舎 広幸, 武舎 るみ |
0 コメント:
コメントを投稿