【发布时间】:2010-05-26 09:33:48
【问题描述】:
我在为 UIImageView 中的图像设置动画时遇到问题。
我在界面生成器中创建了一个图像视图并将其链接到它的 iboutlet。这是我的代码。
@interface Game : UIViewController <UIAccelerometerDelegate>{
IBOutlet UIImageView *diying;
} @property (nonatomic, 保留) UIImageView *diying;
在 viewDidLoad 方法中我写了这段代码
NSArray * imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"Die1.gif"],
[UIImage imageNamed:@"Die2.gif"],
[UIImage imageNamed:@"Die3.gif"],
[UIImage imageNamed:@"Die4.gif"],
nil];
diying.animationImages = imageArray;
diying.animationDuration = 1.1;
diying.contentMode = UIViewContentModeBottomLeft;
[diying startAnimating];
[super viewDidLoad];
这是对我在这里找到的内容的改编:http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/
注意:那些 .gif 文件是简单的图像,没有动画。
我完成了教程,效果很好,但我不知道为什么我的改编不起作用!
【问题讨论】: