我的应用程序中有以下代码,但它没有为UIImageView设置动画,有人可以告诉我原因吗?
UITableViewCell* cell = [selectedTable cellForRowAtIndexPath:selectedPath];
NSArray* myImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked117x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked217x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked317x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked417x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked517x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked617x11" ofType:@"png"]],
nil];
cell.imageView.animationImages = myImageArray;
cell.imageView.animationDuration = 4.20;
cell.imageView.animationRepeatCount = 1;
[cell.imageView startAnimating];
[NSTimer scheduledTimerWithTimeInterval:4.0
target:self
selector:@selector(methodToInvokeAfterAnimationIsDone)
userInfo:nil
repeats:NO];
答案 0 :(得分:2)
你应该用这个:
NSArray* myImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:@"boxBeingChecked117x11.png"]],
[UIImage imageNamed:@"boxBeingChecked217x11.png"]],
[UIImage imageNamed:@"boxBeingChecked317x11.png"]],
[UIImage imageNamed:@"boxBeingChecked417x11.png"]],
[UIImage imageNamed:@"boxBeingChecked517x11.png"]],
[UIImage imageNamed:@"boxBeingChecked617x11.png"]],
nil];
您需要在imageNamed
:method。
答案 1 :(得分:0)
确保imageView
的{{1}}属性设置为highlighted
,否则您上面的代码将无效。如果要为突出显示的图像设置动画,请使用NO
。